@simon-says-build/ssb-overlay 0.8.0 → 0.9.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.
package/README.md CHANGED
@@ -26,6 +26,12 @@ import { captureScreen } from "react-native-view-shot";
26
26
  Nothing secret goes in the bundle: the app's own session token is checked by
27
27
  SSB against the app's backend (functions/in-app.mjs).
28
28
 
29
+ SSB opens as a bottom sheet (0.9.0): half way up with the chat, full screen
30
+ with the work at the top. It needs `@gorhom/bottom-sheet` 5,
31
+ `react-native-reanimated`, `react-native-worklets` and
32
+ `react-native-gesture-handler` in the app (`npx expo install` them; the
33
+ installer does).
34
+
29
35
  ## Help, for everyone who uses the app (0.8.0)
30
36
 
31
37
  `<SsbHelp>` is the web Help widget's native twin (docs/HELPDESK.md): ANY
@@ -18,8 +18,12 @@ const read = (p) => { try { return fs.readFileSync(p, 'utf8'); } catch { return
18
18
  const json = (p) => { try { return JSON.parse(fs.readFileSync(p, 'utf8')); } catch { return null; } };
19
19
  const exists = (p) => fs.existsSync(p);
20
20
 
21
- /** The packages an install adds (react-native-view-shot through `expo install`, so its version fits the SDK). */
22
- export const PACKAGES = ['@simon-says-build/ssb-overlay', '@simon-says-build/demo-player', 'react-native-view-shot'];
21
+ /** The packages an install adds, through `expo install` so native versions fit the SDK:
22
+ * react-native-view-shot for the screen, and the bottom sheet SSB opens in
23
+ * (@gorhom/bottom-sheet with Reanimated, worklets and gesture-handler, 2026-10-22)
24
+ * — an app that has them keeps its own versions. */
25
+ export const PACKAGES = ['@simon-says-build/ssb-overlay', '@simon-says-build/demo-player', 'react-native-view-shot',
26
+ '@gorhom/bottom-sheet', 'react-native-reanimated', 'react-native-worklets', 'react-native-gesture-handler'];
23
27
 
24
28
  // ---- what the app is ----------------------------------------------------------
25
29
  /** Every fact the install decides by, read off the repo. Pure apart from reading files. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simon-says-build/ssb-overlay",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "SSB inside a native app SimonSays controls: the SSB button for the people who change the app (screenshot, mark, ask for a change), and Help for everyone who uses it.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,9 +22,12 @@
22
22
  "README.md"
23
23
  ],
24
24
  "peerDependencies": {
25
+ "@gorhom/bottom-sheet": "^5.2.0",
25
26
  "@simon-says-build/demo-player": ">=0.1.0",
26
27
  "react": ">=18",
27
- "react-native": ">=0.76"
28
+ "react-native": ">=0.76",
29
+ "react-native-gesture-handler": ">=2.16",
30
+ "react-native-reanimated": ">=3.16"
28
31
  },
29
32
  "scripts": {
30
33
  "test": "node --test test/*.test.mjs"
package/src/SsbHost.js CHANGED
@@ -4,10 +4,9 @@
4
4
  // may use it (GET /api/in-app/me: a member of the app's organization, an SSB
5
5
  // operator, or a cast login on the app's allowed list, by default the
6
6
  // super-admin). Then SSB's logo floats on the screen (drag it anywhere).
7
- // Tapping it takes a picture of the screen as it is and opens SSB FULL SCREEN
8
- // (2026-10-20, the product owner: "abandon the idea of a partial overlaying
9
- // sheet … like a full-screen overlay, unless you're in draw / box mode, or
10
- // voice mode"): the WORK at the top — what is in flight on this app, this
7
+ // Tapping it takes a picture of the screen as it is and opens SSB as a SHEET,
8
+ // half way up (2026-10-22: it opened full screen from 2026-10-20 until then);
9
+ // pulled up it is full screen, with the WORK at the top — what is in flight on this app, this
11
10
  // chat's drafts to start — the way the extension's card has it, and the
12
11
  // conversation with SSB below (Tell SSB's, functions/annotate.mjs). Every send carries
13
12
  // the screen (2026-10-19, the product owner: "always send the screen, don't
@@ -20,15 +19,18 @@
20
19
  // No JSX, so it needs nothing from the app's Babel setup beyond React Native's.
21
20
  import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
22
21
  import {
23
- ActivityIndicator, Image, Keyboard, KeyboardAvoidingView, Linking, PanResponder, Platform, Pressable,
24
- NativeModules, ScrollView, StyleSheet, Text, TextInput, View, useWindowDimensions,
22
+ ActivityIndicator, Image, Keyboard, Linking, PanResponder, Platform, Pressable,
23
+ NativeModules, StyleSheet, Text, TextInput, View, useWindowDimensions,
25
24
  } from 'react-native';
26
25
  // The app's demo player (a peer): ▶ Demo hands it the demo to play in this
27
26
  // build. An older player has no playDemo, and the button is not offered.
28
27
  import { playDemo, PLAYER_VERSION } from '@simon-says-build/demo-player';
28
+ // The sheet (see Panel): peers the app already carries.
29
+ import BottomSheet, { BottomSheetBackdrop, BottomSheetFooter, BottomSheetScrollView, BottomSheetTextInput } from '@gorhom/bottom-sheet';
30
+ import { GestureHandlerRootView, ScrollView } from 'react-native-gesture-handler';
29
31
  import {
30
32
  FAB, addPoint, clampFab, demoBanner, fabHome, isDrag, describeHost, draftsOf, fieldTop, inAppApi, namedHosts, newReply, offerOf,
31
- STATE_WORD, boxItem, bundleOriginOf, clientInfo, elsewhereLine, workView, drawingBox, drawingMark, drawingPoint, itemRect, overlayConfig, pollEvery, SNAPSHOT_TOPIC, snapshotOf, talkLine, segmentsOf, sendBody, smallestAt, ssbLinkOf,
33
+ STATE_WORD, workSummary, boxItem, bundleOriginOf, clientInfo, elsewhereLine, workView, drawingBox, drawingMark, drawingPoint, itemRect, overlayConfig, pollEvery, SNAPSHOT_TOPIC, snapshotOf, talkLine, segmentsOf, sendBody, smallestAt, ssbLinkOf,
32
34
  } from './core.js';
33
35
 
34
36
  const h = React.createElement;
@@ -208,19 +210,20 @@ function Host({ config, getToken, sessionKey, route, capture, storage, pushToken
208
210
 
209
211
  const open = mode !== 'idle';
210
212
  useEffect(() => { if (open) load(); }, [open, chatId]);
211
- // The top of the panel: the app's work, asked when it opens and while it stays open.
213
+ // The top of the panel: THIS CONVERSATION's work (2026-10-22: not every job
214
+ // on the app, whoever asked), asked when it opens and while it stays open.
212
215
  const loadWork = useCallback(async () => {
213
- try { const r = await ssb.work(here); setWork(r?.inFlight || []); setElsewhere(r?.readyElsewhere || []); } catch { /* the last list stands */ }
214
- }, [ssb, here]);
216
+ try { const r = await ssb.work(here, chatId || ''); setWork(r?.inFlight || []); setElsewhere(r?.readyElsewhere || []); } catch { /* the last list stands */ }
217
+ }, [ssb, here, chatId]);
215
218
  // ▶ Demo: one demo of everything Ready in this build, played by this build.
216
219
  const startDemo = useCallback(async () => {
217
220
  setBusy(true); setError(null);
218
221
  try {
219
- const r = await ssb.demo(here);
222
+ const r = await ssb.demo(here, chatId || '');
220
223
  if (!playDemo({ id: r.demoId, token: r.token, api: config.api, here: true })) throw new Error('the demo could not start');
221
224
  Keyboard.dismiss(); setMode('idle');
222
225
  } catch (e) { setError(e.message); } finally { setBusy(false); }
223
- }, [ssb, here, config.api]);
226
+ }, [ssb, here, config.api, chatId]);
224
227
  useEffect(() => {
225
228
  if (mode !== 'sheet' || !gate) return undefined;
226
229
  loadWork();
@@ -498,8 +501,27 @@ function Host({ config, getToken, sessionKey, route, capture, storage, pushToken
498
501
  h(View, { ref: chromeRef, collapsable: false, pointerEvents: 'box-none', style: StyleSheet.absoluteFill }, chrome));
499
502
  }
500
503
 
504
+ // THE SHEET (2026-10-22, Michael: "a compact chat as a sheet, where you can
505
+ // expand fully, which shows the persistent panel at the top"). It opens HALF
506
+ // way: the conversation and the composer, with the app still showing above
507
+ // it and the work as one line (workSummary). Pulled up — or the line, or ⌃,
508
+ // tapped — it is the full screen it used to open as, with THE WORK at the top.
509
+ // Pulled down from half, or the backdrop tapped, it closes.
510
+ //
511
+ // @gorhom/bottom-sheet (a peer, with Reanimated and gesture-handler — both
512
+ // apps the overlay ships in already carry all three): its snap points, its
513
+ // keyboard handling (the composer is its TextInput, so the sheet rides the
514
+ // keyboard) and its footer, which keeps the composer on the sheet's visible
515
+ // bottom edge at either height. Its own GestureHandlerRootView, so it works
516
+ // wherever the app put <SsbHost>.
517
+ const SNAPS = ['50%', '100%'];
518
+ const COMPACT = 0, FULL = 1;
519
+
501
520
  function Panel({ gate, chat, work, elsewhere, onDemo, screen, insets, draft, setDraft, busy, error, onSend, onDraw, onClose, onNew, onDecide, onStartAll, onOpenLink, canTalk, talk, onTalk, onEndTalk, onMute }) {
521
+ const sheet = useRef(null);
502
522
  const scroll = useRef(null);
523
+ const [at, setAt] = useState(COMPACT);
524
+ const [footH, setFootH] = useState(120);
503
525
  const [open, setOpen] = useState(null); // the draft whose detail is shown
504
526
  const { flying, waiting, sent } = workView({ inFlight: work, chat });
505
527
  const offer = offerOf(chat);
@@ -508,80 +530,110 @@ function Panel({ gate, chat, work, elsewhere, onDemo, screen, insets, draft, set
508
530
  const ready = flying.filter((x) => x.state === 'ready');
509
531
  const away = elsewhereLine(elsewhere);
510
532
  const hasWork = flying.length || waiting.length || sent.length || banner || away;
533
+ const summary = workSummary({ flying, waiting });
534
+ const full = at === FULL;
511
535
  const showMe = (x) => (x.state === 'ready' && banner?.url ? banner.url : null);
512
- return h(View, { style: [s.panel, { paddingTop: insets.top }], testID: 'ssb-panel' },
513
- h(KeyboardAvoidingView, { behavior: Platform.OS === 'ios' ? 'padding' : undefined, style: { flex: 1 } },
514
- h(View, { style: s.header },
515
- h(View, { style: s.headLogoRing }, h(Image, { source: LOGO, style: s.headLogo, accessibilityLabel: 'SSB' })),
516
- h(View, { style: { flex: 1 } },
517
- h(Text, { style: s.title }, 'Tell SSB'),
518
- h(Text, { style: s.sub, numberOfLines: 1 }, `${gate.app?.name || 'this app'} · as ${gate.person?.label || 'you'}`)),
519
- chat ? h(Pressable, { onPress: onNew, accessibilityRole: 'button', accessibilityLabel: 'New conversation', style: s.quiet }, h(Text, { style: s.quietText }, 'New')) : null,
520
- h(Pressable, { onPress: onClose, accessibilityRole: 'button', accessibilityLabel: 'Close SSB', style: s.iconBtn }, h(Text, { style: s.iconText }, '✕'))),
521
- // THE WORK, at the top: in flight, then drafts to start, then what this chat started.
522
- hasWork ? h(ScrollView, { style: [s.work, { maxHeight: Math.round(screen.height * 0.42) }], testID: 'ssb-work', keyboardShouldPersistTaps: 'handled' },
523
- banner ? h(Pressable, {
524
- testID: 'ssb-demo', disabled: !banner.url, onPress: () => onOpenLink(banner.url),
525
- accessibilityRole: banner.url ? 'button' : 'text', style: [s.demo, banner.url && s.demoReady],
526
- }, h(Text, { style: [s.demoText, banner.url && { color: '#fff' }] }, banner.text), banner.url ? h(Text, { style: s.demoGo }, '▶ See it') : null) : null,
527
- flying.length ? h(View, { style: s.sectionRow },
528
- h(Text, { style: [s.section, { flex: 1 }], testID: 'ssb-section-flight' }, 'In flight'),
529
- ready.length && onDemo ? h(Pressable, { testID: 'ssb-demo-ready', onPress: onDemo, disabled: busy, accessibilityRole: 'button', accessibilityLabel: `Demo what is ready in this build (${ready.length})`, style: [s.primary, s.small, busy && s.disabled] },
530
- h(Text, { style: s.primaryText }, `▶ Demo (${ready.length})`)) : null) : null,
531
- // A row opens its job in the SimonSays app, the console when that app
532
- // is not on the phone (functions/in-app.mjs jobLinksFor) — for those
533
- // who can open it there; anyone else's rows stay plain.
534
- ...flying.map((x) => h(x.links ? Pressable : View, {
535
- key: `f${x.id}`, style: s.workRow, testID: `ssb-flight-${x.id}`,
536
- ...(x.links ? { onPress: () => onOpenLink(x.links.app, x.links.web), accessibilityRole: 'link', accessibilityLabel: `Open in SimonSays: ${x.title}` } : {}),
537
- },
538
- h(Text, { style: s.workTitle, numberOfLines: 2 }, x.links ? `${x.title} ›` : x.title),
539
- showMe(x)
540
- ? h(Pressable, { onPress: () => onOpenLink(showMe(x)), accessibilityRole: 'button', accessibilityLabel: `Show me: ${x.title}`, style: [s.primary, s.small] }, h(Text, { style: s.primaryText }, '▶ Show me'))
541
- : h(Text, { style: [s.state, s[`state_${x.state}`]] }, STATE_WORD[x.state] || x.state))),
542
- away ? h(Text, { style: [s.draftBody, { paddingHorizontal: 16, paddingVertical: 8 }], testID: 'ssb-ready-elsewhere' }, away) : null,
543
- waiting.length ? h(View, { style: s.sectionRow },
544
- h(Text, { style: [s.section, { flex: 1 }] }, 'Drafts'),
545
- waiting.length > 1 ? h(Pressable, { testID: 'ssb-start-all', onPress: onStartAll, disabled: busy, accessibilityRole: 'button', accessibilityLabel: 'Start all', style: [s.primary, s.small, busy && s.disabled] }, h(Text, { style: s.primaryText }, `Start all (${waiting.length})`)) : null) : null,
546
- ...waiting.map((p) => h(View, { key: `d${p.id}`, style: s.draftRow, testID: `ssb-draft-${p.id}` },
547
- h(View, { style: s.workLine },
548
- h(Pressable, { onPress: () => setOpen(open === p.id ? null : p.id), style: { flex: 1 }, accessibilityRole: 'button', accessibilityLabel: p.title },
549
- h(Text, { style: s.workTitle, numberOfLines: open === p.id ? undefined : 2 }, p.title)),
550
- h(Pressable, { testID: `ssb-draft-start-${p.id}`, onPress: () => onDecide(p, 'raise'), disabled: busy, accessibilityRole: 'button', accessibilityLabel: `Start: ${p.title}`, style: [s.primary, s.small, busy && s.disabled] }, h(Text, { style: s.primaryText }, 'Start'))),
551
- open === p.id ? h(View, null,
552
- p.detail ? h(Text, { style: s.draftBody }, p.detail) : null,
553
- h(Pressable, { onPress: () => onDecide(p, 'dismiss'), disabled: busy, accessibilityRole: 'button', accessibilityLabel: `Dismiss: ${p.title}`, style: [s.quiet, { alignSelf: 'flex-start' }] }, h(Text, { style: s.quietText }, 'Dismiss'))) : null)),
554
- ...sent.map((p) => h(View, { key: `s${p.id}`, style: s.workRow, testID: `ssb-sent-${p.id}` },
555
- h(Text, { style: s.workTitle, numberOfLines: 2 }, `✓ ${p.title}`),
556
- p.jobUrl ? h(Pressable, { onPress: () => Linking.openURL(p.jobUrl).catch(() => {}), accessibilityRole: 'link' }, h(Text, { style: s.link }, 'Started →')) : h(Text, { style: s.state }, 'Started')))) : null,
557
- // THE CONVERSATION, below.
558
- h(ScrollView, { ref: scroll, style: s.thread, contentContainerStyle: { paddingVertical: 8 }, keyboardShouldPersistTaps: 'handled', onContentSizeChange: () => scroll.current?.scrollToEnd({ animated: true }) },
559
- msgs.length ? null : h(Text, { style: s.empty }, 'Say what should change on this screen, or tap Draw to scribble on it.'),
560
- ...msgs.map((m) => h(View, { key: m.id, style: [s.bubble, m.role === 'user' ? s.mine : s.theirs] },
561
- m.image ? h(Image, { source: { uri: m.image }, style: s.thumb, resizeMode: 'contain' }) : null,
562
- h(Text, { style: m.role === 'user' ? s.mineText : s.theirsText }, m.text),
563
- m.id === offer ? h(Pressable, { onPress: onStartAll, disabled: busy, style: [s.primary, { marginTop: 8, alignSelf: 'flex-start' }] }, h(Text, { style: s.primaryText }, 'Confirm and start work')) : null)),
564
- chat?.thinking ? h(View, { style: [s.bubble, s.theirs, s.row] }, h(ActivityIndicator, { size: 'small', color: MUTED }), h(Text, { style: [s.theirsText, { marginLeft: 8 }] }, 'SSB is thinking…')) : null),
565
- error ? h(Text, { style: s.error }, error) : null,
566
- // THE COMPOSER, or while talking the voice controls in its place: voice is
567
- // the other way to say it, so Hang up sits where Send does.
568
- h(View, { style: [s.composer, { paddingBottom: Math.max(12, insets.bottom > 60 ? 16 : insets.bottom) }] },
569
- talk ? h(View, { style: s.talkBar, testID: 'ssb-talk-bar' },
570
- h(View, { style: [s.talkDot, talk.status !== 'live' && { backgroundColor: MUTED }] }),
571
- h(Text, { style: s.talkText }, talkLine(talk))) : h(TextInput, {
572
- testID: 'ssb-composer', value: draft, onChangeText: setDraft, multiline: true, placeholder: 'Ask SSB, or say what should change…',
573
- placeholderTextColor: MUTED, keyboardAppearance: 'dark', style: s.input,
574
- }),
575
- h(View, { style: s.row },
576
- h(Pressable, { testID: 'ssb-draw', onPress: onDraw, accessibilityRole: 'button', accessibilityLabel: 'Draw on the screen', style: s.chip }, h(Text, { style: s.chipText }, '✎ Draw')),
577
- canTalk && !talk ? h(Pressable, { testID: 'ssb-talk', onPress: onTalk, accessibilityRole: 'button', accessibilityLabel: 'Talk to SSB', style: s.chip }, h(Text, { style: s.chipText }, '🎙 Talk')) : null,
578
- talk ? h(Pressable, { testID: 'ssb-mute', onPress: onMute, accessibilityRole: 'button', accessibilityLabel: talk.muted ? 'Unmute' : 'Mute', style: s.chip }, h(Text, { style: s.chipText }, talk.muted ? 'Unmute' : 'Mute')) : null,
579
- h(View, { style: { flex: 1 } }),
580
- talk
581
- ? h(Pressable, { testID: 'ssb-hangup', onPress: onEndTalk, accessibilityRole: 'button', accessibilityLabel: 'End the talk', style: [s.primary, s.hangup] }, h(Text, { style: s.primaryText }, 'Hang up'))
582
- : h(Pressable, { testID: 'ssb-send', onPress: onSend, disabled: !draft.trim() || busy, accessibilityRole: 'button', accessibilityLabel: 'Send to SSB', style: [s.primary, (!draft.trim() || busy) && s.disabled] },
583
- busy ? h(ActivityIndicator, { size: 'small', color: '#fff' }) : h(Text, { style: s.primaryText }, 'Send'))))));
536
+ const snap = (i) => sheet.current?.snapToIndex(i);
537
+
538
+ const backdrop = useCallback((p) => h(BottomSheetBackdrop, { ...p, appearsOnIndex: COMPACT, disappearsOnIndex: -1, opacity: 0.45, pressBehavior: 'close' }), []);
539
+
540
+ // THE COMPOSER, or while talking the voice controls in its place: voice is
541
+ // the other way to say it, so Hang up sits where Send does.
542
+ const composer = h(View, { style: [s.composer, { paddingBottom: Math.max(12, insets.bottom > 60 ? 16 : insets.bottom) }], onLayout: (e) => setFootH(e.nativeEvent.layout.height) },
543
+ talk ? h(View, { style: s.talkBar, testID: 'ssb-talk-bar' },
544
+ h(View, { style: [s.talkDot, talk.status !== 'live' && { backgroundColor: MUTED }] }),
545
+ h(Text, { style: s.talkText }, talkLine(talk))) : h(BottomSheetTextInput, {
546
+ testID: 'ssb-composer', value: draft, onChangeText: setDraft, multiline: true, placeholder: 'Ask SSB, or say what should change…',
547
+ placeholderTextColor: MUTED, keyboardAppearance: 'dark', style: s.input,
548
+ }),
549
+ h(View, { style: s.row },
550
+ h(Pressable, { testID: 'ssb-draw', onPress: onDraw, accessibilityRole: 'button', accessibilityLabel: 'Draw on the screen', style: s.chip }, h(Text, { style: s.chipText }, '✎ Draw')),
551
+ canTalk && !talk ? h(Pressable, { testID: 'ssb-talk', onPress: onTalk, accessibilityRole: 'button', accessibilityLabel: 'Talk to SSB', style: s.chip }, h(Text, { style: s.chipText }, '🎙 Talk')) : null,
552
+ talk ? h(Pressable, { testID: 'ssb-mute', onPress: onMute, accessibilityRole: 'button', accessibilityLabel: talk.muted ? 'Unmute' : 'Mute', style: s.chip }, h(Text, { style: s.chipText }, talk.muted ? 'Unmute' : 'Mute')) : null,
553
+ h(View, { style: { flex: 1 } }),
554
+ talk
555
+ ? h(Pressable, { testID: 'ssb-hangup', onPress: onEndTalk, accessibilityRole: 'button', accessibilityLabel: 'End the talk', style: [s.primary, s.hangup] }, h(Text, { style: s.primaryText }, 'Hang up'))
556
+ : h(Pressable, { testID: 'ssb-send', onPress: onSend, disabled: !draft.trim() || busy, accessibilityRole: 'button', accessibilityLabel: 'Send to SSB', style: [s.primary, (!draft.trim() || busy) && s.disabled] },
557
+ busy ? h(ActivityIndicator, { size: 'small', color: '#fff' }) : h(Text, { style: s.primaryText }, 'Send'))));
558
+ // The footer is a component TYPE to the sheet: a new function per keystroke
559
+ // remounted the text box after every letter (the harness sent "T" for a
560
+ // sentence). So it is made once, and the composer reaches it by context.
561
+ const footer = useCallback((p) => h(BottomSheetFooter, p, h(ComposerSlot)), []);
562
+
563
+ // THE WORK, at the top of the full sheet: in flight, then drafts to start, then what this chat started.
564
+ const workList = h(ScrollView, { style: [s.work, { maxHeight: Math.round(screen.height * 0.42) }], testID: 'ssb-work', keyboardShouldPersistTaps: 'handled' },
565
+ banner ? h(Pressable, {
566
+ testID: 'ssb-demo', disabled: !banner.url, onPress: () => onOpenLink(banner.url),
567
+ accessibilityRole: banner.url ? 'button' : 'text', style: [s.demo, banner.url && s.demoReady],
568
+ }, h(Text, { style: [s.demoText, banner.url && { color: '#fff' }] }, banner.text), banner.url ? h(Text, { style: s.demoGo }, '▶ See it') : null) : null,
569
+ flying.length ? h(View, { style: s.sectionRow },
570
+ h(Text, { style: [s.section, { flex: 1 }], testID: 'ssb-section-flight' }, 'In flight'),
571
+ ready.length && onDemo ? h(Pressable, { testID: 'ssb-demo-ready', onPress: onDemo, disabled: busy, accessibilityRole: 'button', accessibilityLabel: `Demo what is ready in this build (${ready.length})`, style: [s.primary, s.small, busy && s.disabled] },
572
+ h(Text, { style: s.primaryText }, `▶ Demo (${ready.length})`)) : null) : null,
573
+ // A row opens its job in the SimonSays app, the console when that app
574
+ // is not on the phone (functions/in-app.mjs jobLinksFor) — for those
575
+ // who can open it there; anyone else's rows stay plain.
576
+ ...flying.map((x) => h(x.links ? Pressable : View, {
577
+ key: `f${x.id}`, style: s.workRow, testID: `ssb-flight-${x.id}`,
578
+ ...(x.links ? { onPress: () => onOpenLink(x.links.app, x.links.web), accessibilityRole: 'link', accessibilityLabel: `Open in SimonSays: ${x.title}` } : {}),
579
+ },
580
+ h(Text, { style: s.workTitle, numberOfLines: 2 }, x.links ? `${x.title} ›` : x.title),
581
+ showMe(x)
582
+ ? h(Pressable, { onPress: () => onOpenLink(showMe(x)), accessibilityRole: 'button', accessibilityLabel: `Show me: ${x.title}`, style: [s.primary, s.small] }, h(Text, { style: s.primaryText }, '▶ Show me'))
583
+ : h(Text, { style: [s.state, s[`state_${x.state}`]] }, STATE_WORD[x.state] || x.state))),
584
+ away ? h(Text, { style: [s.draftBody, { paddingHorizontal: 16, paddingVertical: 8 }], testID: 'ssb-ready-elsewhere' }, away) : null,
585
+ waiting.length ? h(View, { style: s.sectionRow },
586
+ h(Text, { style: [s.section, { flex: 1 }] }, 'Drafts'),
587
+ waiting.length > 1 ? h(Pressable, { testID: 'ssb-start-all', onPress: onStartAll, disabled: busy, accessibilityRole: 'button', accessibilityLabel: 'Start all', style: [s.primary, s.small, busy && s.disabled] }, h(Text, { style: s.primaryText }, `Start all (${waiting.length})`)) : null) : null,
588
+ ...waiting.map((p) => h(View, { key: `d${p.id}`, style: s.draftRow, testID: `ssb-draft-${p.id}` },
589
+ h(View, { style: s.workLine },
590
+ h(Pressable, { onPress: () => setOpen(open === p.id ? null : p.id), style: { flex: 1 }, accessibilityRole: 'button', accessibilityLabel: p.title },
591
+ h(Text, { style: s.workTitle, numberOfLines: open === p.id ? undefined : 2 }, p.title)),
592
+ h(Pressable, { testID: `ssb-draft-start-${p.id}`, onPress: () => onDecide(p, 'raise'), disabled: busy, accessibilityRole: 'button', accessibilityLabel: `Start: ${p.title}`, style: [s.primary, s.small, busy && s.disabled] }, h(Text, { style: s.primaryText }, 'Start'))),
593
+ open === p.id ? h(View, null,
594
+ p.detail ? h(Text, { style: s.draftBody }, p.detail) : null,
595
+ h(Pressable, { onPress: () => onDecide(p, 'dismiss'), disabled: busy, accessibilityRole: 'button', accessibilityLabel: `Dismiss: ${p.title}`, style: [s.quiet, { alignSelf: 'flex-start' }] }, h(Text, { style: s.quietText }, 'Dismiss'))) : null)),
596
+ ...sent.map((p) => h(View, { key: `s${p.id}`, style: s.workRow, testID: `ssb-sent-${p.id}` },
597
+ h(Text, { style: s.workTitle, numberOfLines: 2 }, `✓ ${p.title}`),
598
+ p.jobUrl ? h(Pressable, { onPress: () => Linking.openURL(p.jobUrl).catch(() => {}), accessibilityRole: 'link' }, h(Text, { style: s.link }, 'Started →')) : h(Text, { style: s.state }, 'Started'))));
599
+
600
+ // Half open: the work is one line, and a ready demo keeps its button —
601
+ // it is the thing most worth a tap.
602
+ const compactWork = (summary || banner) ? h(Pressable, { testID: 'ssb-work-summary', onPress: () => snap(FULL), accessibilityRole: 'button', accessibilityLabel: `Show the work: ${summary || banner.text}`, style: s.summary },
603
+ h(Text, { style: s.summaryText, numberOfLines: 1 }, summary || banner.text),
604
+ banner?.url ? h(Pressable, { testID: 'ssb-demo', onPress: () => onOpenLink(banner.url), accessibilityRole: 'button', style: [s.primary, s.small] }, h(Text, { style: s.primaryText }, '▶ See it')) : null,
605
+ h(Text, { style: s.summaryGo }, '⌃')) : null;
606
+
607
+ return h(GestureHandlerRootView, { style: StyleSheet.absoluteFill, pointerEvents: 'box-none' },
608
+ h(ComposerCtx.Provider, { value: composer }, h(BottomSheet, {
609
+ ref: sheet, index: COMPACT, snapPoints: SNAPS, enableDynamicSizing: false, enablePanDownToClose: true,
610
+ topInset: insets.top, onChange: (i) => { if (i >= 0) setAt(i); }, onClose,
611
+ backdropComponent: backdrop, footerComponent: footer,
612
+ keyboardBehavior: 'interactive', keyboardBlurBehavior: 'restore', android_keyboardInputMode: 'adjustResize',
613
+ backgroundStyle: s.sheetBg, handleIndicatorStyle: s.grabber,
614
+ },
615
+ h(View, { style: { flex: 1 }, testID: 'ssb-panel' },
616
+ h(View, { style: s.header },
617
+ h(View, { style: s.headLogoRing }, h(Image, { source: LOGO, style: s.headLogo, accessibilityLabel: 'SSB' })),
618
+ h(View, { style: { flex: 1 } },
619
+ h(Text, { style: s.title }, 'Tell SSB'),
620
+ h(Text, { style: s.sub, numberOfLines: 1 }, `${gate.app?.name || 'this app'} · as ${gate.person?.label || 'you'}`)),
621
+ chat ? h(Pressable, { onPress: onNew, accessibilityRole: 'button', accessibilityLabel: 'New conversation', style: s.quiet }, h(Text, { style: s.quietText }, 'New')) : null,
622
+ h(Pressable, { testID: full ? 'ssb-collapse' : 'ssb-expand', onPress: () => snap(full ? COMPACT : FULL), accessibilityRole: 'button', accessibilityLabel: full ? 'Make SSB smaller' : 'Open SSB full screen', style: s.iconBtn }, h(Text, { style: s.iconText }, full ? '⌄' : '⌃')),
623
+ h(Pressable, { testID: 'ssb-close', onPress: () => sheet.current?.close(), accessibilityRole: 'button', accessibilityLabel: 'Close SSB', style: s.iconBtn }, h(Text, { style: s.iconText }, '✕'))),
624
+ full ? (hasWork ? workList : null) : compactWork,
625
+ // THE CONVERSATION, below; the footer (the composer) floats over its end.
626
+ h(BottomSheetScrollView, { ref: scroll, style: s.thread, contentContainerStyle: { paddingTop: 8, paddingBottom: footH + 8 }, keyboardShouldPersistTaps: 'handled', onContentSizeChange: () => scroll.current?.scrollToEnd({ animated: true }) },
627
+ msgs.length ? null : h(Text, { style: s.empty }, 'Say what should change on this screen, or tap Draw to scribble on it.'),
628
+ ...msgs.map((m) => h(View, { key: m.id, style: [s.bubble, m.role === 'user' ? s.mine : s.theirs] },
629
+ m.image ? h(Image, { source: { uri: m.image }, style: s.thumb, resizeMode: 'contain' }) : null,
630
+ h(Text, { style: m.role === 'user' ? s.mineText : s.theirsText }, m.text),
631
+ m.id === offer ? h(Pressable, { onPress: onStartAll, disabled: busy, style: [s.primary, { marginTop: 8, alignSelf: 'flex-start' }] }, h(Text, { style: s.primaryText }, 'Confirm and start work')) : null)),
632
+ chat?.thinking ? h(View, { style: [s.bubble, s.theirs, s.row] }, h(ActivityIndicator, { size: 'small', color: MUTED }), h(Text, { style: [s.theirsText, { marginLeft: 8 }] }, 'SSB is thinking…')) : null,
633
+ error ? h(Text, { style: s.error }, error) : null)))));
584
634
  }
635
+ const ComposerCtx = React.createContext(null);
636
+ const ComposerSlot = () => React.useContext(ComposerCtx);
585
637
 
586
638
  const shadow = { shadowColor: '#000', shadowOpacity: 0.45, shadowRadius: 18, shadowOffset: { width: 0, height: 8 }, elevation: 12 };
587
639
  const glow = (c, r = 12) => ({ shadowColor: c, shadowOpacity: 0.55, shadowRadius: r, shadowOffset: { width: 0, height: 0 } });
@@ -611,8 +663,12 @@ const s = StyleSheet.create({
611
663
  // The panel. Spelled out: StyleSheet.absoluteFillObject is gone in React
612
664
  // Native 0.86, and spreading `undefined` left the panel with no size at all
613
665
  // (the harness caught it).
614
- panel: { position: 'absolute', top: 0, left: 0, right: 0, bottom: 0, backgroundColor: BG },
615
- header: { flexDirection: 'row', alignItems: 'center', gap: 12, paddingTop: 12, paddingHorizontal: 16, paddingBottom: 12, borderBottomWidth: 1, borderBottomColor: LINE },
666
+ sheetBg: { backgroundColor: BG, borderTopLeftRadius: 22, borderTopRightRadius: 22, borderWidth: 1, borderColor: LINE },
667
+ grabber: { backgroundColor: MUTED, width: 40 },
668
+ summary: { flexDirection: 'row', alignItems: 'center', gap: 10, paddingHorizontal: 16, paddingVertical: 10, borderBottomWidth: 1, borderBottomColor: LINE, backgroundColor: SURFACE },
669
+ summaryText: { flex: 1, fontSize: 13, fontWeight: '700', color: TEXT },
670
+ summaryGo: { color: MUTED, fontSize: 16, fontWeight: '800' },
671
+ header: { flexDirection: 'row', alignItems: 'center', gap: 12, paddingTop: 4, paddingHorizontal: 16, paddingBottom: 12, borderBottomWidth: 1, borderBottomColor: LINE },
616
672
  headLogoRing: { width: 40, height: 40, borderRadius: 20, ...glow(BLUE, 10) },
617
673
  headLogo: { width: 40, height: 40, borderRadius: 20 },
618
674
  title: { fontSize: 17, fontWeight: '800', color: TEXT, letterSpacing: 0.3 },
package/src/core.js CHANGED
@@ -5,7 +5,7 @@
5
5
  export const DEFAULT_API = 'https://simonsays.build';
6
6
  // What this overlay is, said when it registers for pushes (clientInfo below).
7
7
  // Kept equal to package.json by test/core.test.mjs.
8
- export const OVERLAY_VERSION = '0.8.0';
8
+ export const OVERLAY_VERSION = '0.9.0';
9
9
  export const HOST = 5;
10
10
  export const TEXT = 6;
11
11
  const PIN_SLOP = 12; // a drag shorter than this is a tap: a pin, not a box
@@ -49,8 +49,12 @@ export function inAppApi(config, getToken, fetchImpl = globalThis.fetch) {
49
49
  voice: (body) => post('/voice', body),
50
50
  // `bundle`: where this app's JS came from (a preview's tunnel), so SSB
51
51
  // scopes Ready to this build; undefined = the whole list, as before.
52
- work: (bundle) => call(bundle === undefined ? '/work' : `/work?bundle=${encodeURIComponent(bundle)}`),
53
- demo: (bundle) => post('/demo', { bundle }),
52
+ // `chat`: only this conversation's work ("" before there is one: nothing).
53
+ work: (bundle, chat) => {
54
+ const q = [bundle === undefined ? null : `bundle=${encodeURIComponent(bundle)}`, chat === undefined ? null : `chat=${encodeURIComponent(chat || '')}`].filter(Boolean);
55
+ return call(q.length ? `/work?${q.join('&')}` : '/work');
56
+ },
57
+ demo: (bundle, chatId) => post('/demo', { bundle, ...(chatId !== undefined ? { chatId: chatId || '' } : {}) }),
54
58
  };
55
59
  }
56
60
 
@@ -316,6 +320,22 @@ export function workView({ inFlight = [], chat = null } = {}) {
316
320
  return { flying, waiting, sent: sent.filter((p) => !p.jobId || !flyingIds.has(p.jobId)) };
317
321
  }
318
322
 
323
+ // The COMPACT sheet's one line about the work (2026-10-22): the full sheet
324
+ // lists it at the top; half-open, the chat has the room and the work is a
325
+ // line that says how much there is — tap it, or pull the sheet up, to see it.
326
+ // Ready first (it is what to look at), then the rest by state, then drafts.
327
+ // "" when there is nothing, so the line is not drawn.
328
+ export function workSummary({ flying = [], waiting = [] } = {}) {
329
+ const n = {};
330
+ for (const x of flying) n[x.state] = (n[x.state] || 0) + 1;
331
+ const parts = ['ready', 'building', 'checking', 'queued', 'blocked']
332
+ .filter((k) => n[k]).map((k) => `${n[k]} ${(STATE_WORD[k] || k).toLowerCase()}`);
333
+ const other = flying.length - parts.reduce((a, p) => a + Number(p.split(' ')[0]), 0);
334
+ if (other > 0) parts.push(`${other} in flight`);
335
+ if (waiting.length) parts.push(`${waiting.length} draft${waiting.length === 1 ? '' : 's'} to start`);
336
+ return parts.join(' · ');
337
+ }
338
+
319
339
  // READY IS THIS BUILD (2026-10-20, docs/IN-APP-SSB.md): the origin the app's
320
340
  // JS bundle was loaded from — a preview's tunnel — or "" for a build that
321
341
  // loads from a file (a store or local build, which holds no SSB preview).