@vibes.diy/base 14.3.453 → 14.3.454

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.
@@ -21,6 +21,9 @@ export interface HandleLookupViewProps {
21
21
  readonly className?: string;
22
22
  readonly invalid?: boolean;
23
23
  readonly busy?: boolean;
24
+ readonly allowRawHandle?: boolean;
25
+ readonly notice?: string;
24
26
  }
27
+ export declare const HANDLE_LOOKUP_PICK_HINT = "Pick someone from the list, or type their email to invite them.";
25
28
  export declare function sanitizeTypedHandle(query: string): string;
26
- export declare function HandleLookupView({ value, query, items, onQueryChange, onSelect, onClear, renderTag, placeholder, disabled, style, inputClassName, className, invalid, busy, }: HandleLookupViewProps): React.ReactElement;
29
+ export declare function HandleLookupView({ value, query, items, onQueryChange, onSelect, onClear, renderTag, placeholder, disabled, style, inputClassName, className, invalid, busy, allowRawHandle, notice, }: HandleLookupViewProps): React.ReactElement;
@@ -1,6 +1,7 @@
1
1
  import * as React from "react";
2
2
  import { useEffect, useRef, useState } from "react";
3
3
  import { toRFC2822_32ByteLength } from "@vibes.diy/vibe-types";
4
+ export const HANDLE_LOOKUP_PICK_HINT = "Pick someone from the list, or type their email to invite them.";
4
5
  const DEFAULT_INPUT_STYLE = {
5
6
  width: "100%",
6
7
  boxSizing: "border-box",
@@ -16,7 +17,7 @@ export function sanitizeTypedHandle(query) {
16
17
  return toRFC2822_32ByteLength(query.trim().replace(/^@+/, ""));
17
18
  }
18
19
  const sanitize = sanitizeTypedHandle;
19
- export function HandleLookupView({ value, query, items, onQueryChange, onSelect, onClear, renderTag, placeholder, disabled, style, inputClassName, className, invalid, busy, }) {
20
+ export function HandleLookupView({ value, query, items, onQueryChange, onSelect, onClear, renderTag, placeholder, disabled, style, inputClassName, className, invalid, busy, allowRawHandle = true, notice, }) {
20
21
  const [open, setOpen] = useState(false);
21
22
  const [highlight, setHighlight] = useState(-1);
22
23
  const rootRef = useRef(null);
@@ -68,7 +69,10 @@ export function HandleLookupView({ value, query, items, onQueryChange, onSelect,
68
69
  }
69
70
  const sanitized = sanitize(query);
70
71
  const emailItem = items.find((it) => it.kind === "email");
71
- const canCommitRaw = sanitized.length > 0 && emailItem === undefined;
72
+ const canCommitRaw = allowRawHandle && sanitized.length > 0 && emailItem === undefined;
73
+ const exactItem = items.find((it) => it.kind !== "email" && it.slug === sanitized);
74
+ const showPickHint = !allowRawHandle && sanitized.length > 0 && emailItem === undefined && exactItem === undefined;
75
+ const statusLine = notice ?? (showPickHint ? HANDLE_LOOKUP_PICK_HINT : undefined);
72
76
  const commit = (slug) => {
73
77
  onSelect(slug);
74
78
  setOpen(false);
@@ -93,6 +97,8 @@ export function HandleLookupView({ value, query, items, onQueryChange, onSelect,
93
97
  commit(emailItem.slug);
94
98
  else if (canCommitRaw)
95
99
  commit(sanitized);
100
+ else if (exactItem)
101
+ commit(exactItem.slug);
96
102
  }
97
103
  else if (e.key === "Escape") {
98
104
  e.preventDefault();
@@ -106,6 +112,7 @@ export function HandleLookupView({ value, query, items, onQueryChange, onSelect,
106
112
  onQueryChange(e.target.value);
107
113
  setOpen(true);
108
114
  }, onFocus: () => setOpen(true), onKeyDown: onKeyDown, autoCapitalize: "off", autoComplete: "off", spellCheck: false, "aria-invalid": invalid === true ? true : undefined, "aria-busy": busy === true ? true : undefined, className: inputClassName, style: inputClassName === undefined ? DEFAULT_INPUT_STYLE : undefined }),
115
+ statusLine !== undefined && (React.createElement("div", { role: "status", style: { marginTop: 4, fontSize: 12, lineHeight: 1.35, color: "var(--text-secondary, var(--muted, #888))" } }, statusLine)),
109
116
  open && (items.length > 0 || canCommitRaw) && (React.createElement("div", { role: "listbox", "aria-label": "Matching handles", style: {
110
117
  position: "absolute",
111
118
  top: "calc(100% + 6px)",
@@ -1,5 +1,5 @@
1
1
  import { useEffect, useMemo, useRef, useState } from "react";
2
- import { isEmailContact } from "@vibes.diy/vibe-types";
2
+ import { findEmailContact } from "@vibes.diy/vibe-types";
3
3
  import { sanitizeTypedHandle } from "./HandleLookupView.js";
4
4
  import { mergeKnownCache } from "./handle-known-cache.js";
5
5
  const DEBOUNCE_MS = 200;
@@ -55,10 +55,8 @@ export function useHandleLookupItems(query, lookup) {
55
55
  const knownMatches = (known ?? []).filter((h) => prefix.length === 0 || h.startsWith(prefix)).sort();
56
56
  const seen = new Set(knownMatches);
57
57
  const globals = globalHandles.filter((h) => h.startsWith(prefix) && !seen.has(h));
58
- const address = query.trim();
59
- const email = isEmailContact(address)
60
- ? [{ slug: address, known: false, kind: "email", label: "Invite by email" }]
61
- : [];
58
+ const address = findEmailContact(query);
59
+ const email = address !== undefined ? [{ slug: address, known: false, kind: "email", label: "Invite by email" }] : [];
62
60
  return [
63
61
  ...email,
64
62
  ...knownMatches.map((slug) => ({ slug, known: true, avatarUrl: avatarUrlFor(slug) })),
@@ -75,8 +75,9 @@ export function VibeMenu(props) {
75
75
  if (foldSeen.open !== menuOpen || foldSeen.key !== props.openingKey) {
76
76
  const opening = (foldSeen.open === false && menuOpen) || foldSeen.key !== props.openingKey;
77
77
  setFoldSeen({ open: menuOpen, key: props.openingKey });
78
- if (opening && fold !== (chatOnly ? "open" : "closed"))
79
- setFold(chatOnly ? "open" : "closed");
78
+ const rest = chatOnly || props.logOpenOnOpening === true ? "open" : "closed";
79
+ if (opening && fold !== rest)
80
+ setFold(rest);
80
81
  }
81
82
  const [chatOnlySeen, setChatOnlySeen] = useState(chatOnly);
82
83
  if (chatOnlySeen !== chatOnly) {
@@ -126,9 +126,10 @@ export interface ComposerProps {
126
126
  readonly placeholder?: string;
127
127
  readonly fieldRef?: React.Ref<HTMLTextAreaElement>;
128
128
  readonly coarsePointer?: () => boolean;
129
+ readonly now?: () => number;
129
130
  }
130
131
  export declare const STOP_GUARD_MS = 4000;
131
132
  export declare function stopGuardHolds(now: number, armedAt: number | undefined): boolean;
132
- export declare function useStopGuardHolds(armedAt: number | undefined): boolean;
133
+ export declare function useStopGuardHolds(armedAt: number | undefined, now?: () => number): boolean;
133
134
  export declare function latestStopArm(...armedAt: readonly (number | undefined)[]): number | undefined;
134
135
  export declare function Composer(props: ComposerProps): React.ReactElement;
@@ -115,18 +115,18 @@ export const STOP_GUARD_MS = 4000;
115
115
  export function stopGuardHolds(now, armedAt) {
116
116
  return armedAt !== undefined && now - armedAt < STOP_GUARD_MS;
117
117
  }
118
- export function useStopGuardHolds(armedAt) {
118
+ export function useStopGuardHolds(armedAt, now = Date.now) {
119
119
  const [, repaint] = React.useState(0);
120
- const holds = stopGuardHolds(Date.now(), armedAt);
120
+ const holds = stopGuardHolds(now(), armedAt);
121
121
  React.useEffect(() => {
122
122
  if (armedAt === undefined)
123
123
  return;
124
- const left = armedAt + STOP_GUARD_MS - Date.now();
124
+ const left = armedAt + STOP_GUARD_MS - now();
125
125
  if (left <= 0)
126
126
  return;
127
127
  const timer = setTimeout(() => repaint((n) => n + 1), left);
128
128
  return () => clearTimeout(timer);
129
- }, [armedAt]);
129
+ }, [armedAt, now]);
130
130
  return holds;
131
131
  }
132
132
  export function latestStopArm(...armedAt) {
@@ -272,7 +272,8 @@ export function Composer(props) {
272
272
  const fileInput = React.useRef(null);
273
273
  const building = composer.cap === "Stop";
274
274
  const [stopArmedAt, setStopArmedAt] = React.useState(undefined);
275
- const stopHeld = useStopGuardHolds(stopArmedAt);
275
+ const now = props.now ?? Date.now;
276
+ const stopHeld = useStopGuardHolds(stopArmedAt, now);
276
277
  const wasBuilding = React.useRef(building);
277
278
  const queueSentAt = React.useRef(undefined);
278
279
  const hadQueue = React.useRef(draft.queued.length > 0);
@@ -296,10 +297,20 @@ export function Composer(props) {
296
297
  const queuedCount = draft.queued.length;
297
298
  const draftRef = React.useRef(draft);
298
299
  draftRef.current = draft;
300
+ const buildingRef = React.useRef(building);
301
+ buildingRef.current = building;
302
+ const dictationArmed = React.useRef(false);
303
+ const armStopIfBuilding = React.useCallback(() => {
304
+ if (buildingRef.current === false)
305
+ return;
306
+ dictationArmed.current = true;
307
+ setStopArmedAt(now());
308
+ }, [now]);
299
309
  const dictation = useDictation({
300
310
  surface: "change",
301
311
  scope: draft.scope ?? null,
302
312
  onText: (words) => {
313
+ armStopIfBuilding();
303
314
  const latest = draftRef.current;
304
315
  latest.setText(joinDictated(latest.text, words));
305
316
  const field = box.current?.querySelector("textarea");
@@ -311,17 +322,26 @@ export function Composer(props) {
311
322
  });
312
323
  const dictating = dictation.phase === "recording" || dictation.phase === "opening";
313
324
  const transcribing = dictation.phase === "transcribing";
325
+ const wasDictating = React.useRef(dictating);
326
+ React.useEffect(() => {
327
+ if (wasDictating.current === true && dictating === false)
328
+ armStopIfBuilding();
329
+ wasDictating.current = dictating;
330
+ }, [dictating, armStopIfBuilding]);
314
331
  React.useEffect(() => {
315
332
  if (hadQueue.current === true && queuedCount === 0 && wasBuilding.current === false)
316
- queueSentAt.current = Date.now();
333
+ queueSentAt.current = now();
317
334
  hadQueue.current = queuedCount > 0;
318
335
  }, [queuedCount, building]);
319
336
  React.useEffect(() => {
320
337
  if (building === true && wasBuilding.current === false) {
321
- const fromThisBox = queuedCount > 0 || stopGuardHolds(Date.now(), queueSentAt.current);
338
+ const fromThisBox = queuedCount > 0 || stopGuardHolds(now(), queueSentAt.current);
322
339
  queueSentAt.current = undefined;
323
- if (fromThisBox)
324
- setStopArmedAt((armed) => (stopGuardHolds(Date.now(), armed) ? armed : Date.now()));
340
+ if (fromThisBox) {
341
+ if (stopGuardHolds(now(), stopArmedAt) === false)
342
+ dictationArmed.current = false;
343
+ setStopArmedAt((armed) => (stopGuardHolds(now(), armed) ? armed : now()));
344
+ }
325
345
  }
326
346
  if (building === false)
327
347
  setStopping(false);
@@ -345,7 +365,8 @@ export function Composer(props) {
345
365
  const sending = draft.text.trim();
346
366
  if (draft.submit() === true) {
347
367
  seedPrefill.sent(sending);
348
- setStopArmedAt(Date.now());
368
+ dictationArmed.current = false;
369
+ setStopArmedAt(now());
349
370
  foldKeyboardAfterSend({ boxes: [box.current], coarsePointer: props.coarsePointer });
350
371
  return;
351
372
  }
@@ -375,7 +396,7 @@ export function Composer(props) {
375
396
  focusField();
376
397
  }
377
398
  function stop() {
378
- if (stopping === true || stopGuardHolds(Date.now(), stopArmedAt))
399
+ if (stopping === true || transcribing || stopGuardHolds(now(), stopArmedAt))
379
400
  return;
380
401
  setStopping(true);
381
402
  draft.stop();
@@ -390,6 +411,7 @@ export function Composer(props) {
390
411
  return;
391
412
  submit("enter");
392
413
  }
414
+ const stopHeldLabel = transcribing || dictationArmed.current ? "Adding your words…" : "Sending…";
393
415
  const drop = composerFileDrop({ onFiles: attachments.add });
394
416
  const leftOutNote = leftOutSentence(attachments.leftOut);
395
417
  const next = composer.hold?.next;
@@ -416,10 +438,13 @@ export function Composer(props) {
416
438
  React.createElement("button", { className: "vm-dictate-cancel", type: "button", "aria-label": "Stop recording and discard it", onClick: dictation.cancel },
417
439
  React.createElement(DictationCancelIcon, null)),
418
440
  React.createElement(DictationWave, { analyser: dictation.analyser, startedAt: dictation.startedAt }),
419
- React.createElement("button", { className: "vm-dictate-done", type: "button", "aria-label": "Done speaking: add the words", autoFocus: true, onClick: dictation.finish },
441
+ React.createElement("button", { className: "vm-dictate-done", type: "button", "aria-label": "Done speaking: add the words", autoFocus: true, onClick: () => {
442
+ armStopIfBuilding();
443
+ dictation.finish();
444
+ } },
420
445
  React.createElement(DictationCheckIcon, null)))) : dictation.available && composer.disabled !== true ? (React.createElement("button", { className: "vm-mic", type: "button", "aria-label": transcribing ? "Writing down what you said" : "Speak instead of typing", title: transcribing ? undefined : "Speak instead of typing", "aria-busy": transcribing ? true : undefined, disabled: transcribing, "data-transcribing": transcribing ? "" : undefined, onClick: dictation.start }, transcribing ? React.createElement(DictationSpinner, null) : React.createElement(MicIcon, null))) : null,
421
446
  building ? (React.createElement(React.Fragment, null,
422
- React.createElement("button", { className: "vm-cap", type: "button", "data-stop": "", "data-stopping": stopping === true ? "" : undefined, "data-stop-held": stopHeld === true && stopping === false ? "" : undefined, "aria-busy": stopping === true || stopHeld === true ? true : undefined, disabled: composer.stopDisabled === true || stopping === true || stopHeld === true, onClick: stop }, stopping === true ? "Stopping…" : stopHeld === true ? "Sending…" : "Stop"),
447
+ React.createElement("button", { className: "vm-cap", type: "button", "data-stop": "", "data-stopping": stopping === true ? "" : undefined, "data-stop-held": (stopHeld === true || transcribing) && stopping === false ? "" : undefined, "aria-busy": stopping === true || stopHeld === true || transcribing ? true : undefined, disabled: composer.stopDisabled === true || stopping === true || stopHeld === true || transcribing, onClick: stop }, stopping === true ? "Stopping…" : stopHeld === true || transcribing ? stopHeldLabel : "Stop"),
423
448
  sendCap)) : (sendCap)),
424
449
  dictation.note !== undefined ? (React.createElement("p", { className: "vm-queue-note", role: "status", "data-dictation-note": "" }, dictation.note)) : null,
425
450
  composer.hold !== undefined ? (refused === "credits" || ideaHeld ? null : (React.createElement(HoldNote, { hold: composer.hold }))) : composer.queuedNote ? (React.createElement("p", { className: "vm-queue-note" }, "Sends when this finishes.")) : null,
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- export type StatusChipId = "keepAsk" | "examplesCleared" | "nextStep" | "buildAsk" | "shareReach" | "pending" | "admin" | "draft" | "locked" | "editing";
2
+ export type StatusChipId = "keepAsk" | "examplesCleared" | "nextStep" | "buildAsk" | "howTo" | "shareReach" | "pending" | "admin" | "draft" | "locked" | "editing";
3
3
  export declare const STATUS_CHIP_PRIORITY: Readonly<Record<StatusChipId, number>>;
4
4
  export declare const ADMIN_BADGE_TEXT = "Admin";
5
5
  export declare const ADMIN_BADGE_LABEL = "Admin mode is on for this page \u2014 you're seeing everyone's data.";
@@ -65,7 +65,12 @@ export interface StatusChipInputs {
65
65
  readonly label: string;
66
66
  onTap(): void;
67
67
  } | null;
68
+ readonly howTo?: {
69
+ readonly line: string;
70
+ onTap(): void;
71
+ } | null;
68
72
  }
73
+ export declare function howToNoteLabel(line: string): string;
69
74
  export declare const BUILD_ASK_TEXT_MAX = 44;
70
75
  export declare const BUILD_ASK_CHIP_TEXT = "A question for you";
71
76
  export declare function buildAskChipText(question: string): string;
@@ -6,6 +6,7 @@ export const STATUS_CHIP_PRIORITY = Object.freeze({
6
6
  examplesCleared: 0,
7
7
  nextStep: 1,
8
8
  buildAsk: 1,
9
+ howTo: 1,
9
10
  shareReach: 1,
10
11
  pending: 1,
11
12
  admin: 2,
@@ -60,6 +61,9 @@ export function nextStepChipLabel(label) {
60
61
  export function pendingChipText(n) {
61
62
  return `${n} waiting`;
62
63
  }
64
+ export function howToNoteLabel(line) {
65
+ return `How to use your app: ${line.trim()} Tap to open the Agent log.`;
66
+ }
63
67
  export const BUILD_ASK_TEXT_MAX = 44;
64
68
  export const BUILD_ASK_CHIP_TEXT = "A question for you";
65
69
  export function buildAskChipText(question) {
@@ -84,6 +88,7 @@ export const FLOATING_ONLY_CHIPS = new Set([
84
88
  "buildAsk",
85
89
  "keepAsk",
86
90
  "shareReach",
91
+ "howTo",
87
92
  ]);
88
93
  export function statusChipsFor(b, handlers) {
89
94
  const chips = [];
@@ -116,6 +121,8 @@ export function statusChipsFor(b, handlers) {
116
121
  onTap: b.buildAsk.onTap,
117
122
  });
118
123
  }
124
+ if (b.howTo !== undefined && b.howTo !== null && b.howTo.line.trim().length > 0)
125
+ chips.push({ id: "howTo", text: b.howTo.line.trim(), label: howToNoteLabel(b.howTo.line), onTap: b.howTo.onTap });
119
126
  if (b.shareReach !== undefined && b.shareReach !== null)
120
127
  chips.push({ id: "shareReach", text: b.shareReach.text, label: b.shareReach.label, onTap: b.shareReach.onTap });
121
128
  if (b.pendingRequests > 0) {
@@ -434,6 +434,21 @@ export const VIBE_MENU_SHELL_CSS = `
434
434
  overflow: hidden;
435
435
  text-overflow: ellipsis;
436
436
  }
437
+ /* #7919 the how-to note: the agent's closing line reads whole, wrapped to
438
+ three lines at most, with Code's colour as a bar on its leading edge. */
439
+ .vm-layer .vm-chip-row[data-place="floating"] .vm-chip-pill[data-chip="howTo"] {
440
+ display: -webkit-box;
441
+ -webkit-box-orient: vertical;
442
+ -webkit-line-clamp: 3;
443
+ overflow: hidden;
444
+ height: auto;
445
+ /* The breathing room is a border, outside the clip, so a fourth line never shows in it. */
446
+ padding: 0 4px 0 12px;
447
+ border-block: 6px solid transparent;
448
+ white-space: normal;
449
+ box-shadow: inset 4px 0 0 var(--section-code);
450
+ font: 600 12px/18px var(--font-tab);
451
+ }
437
452
  .vm-layer .vm-chip-row[data-place="floating"] .vm-chip-pill[data-chip="pending"] {
438
453
  flex: none;
439
454
  align-self: flex-start;
@@ -380,6 +380,10 @@ export interface VibeMenuProps {
380
380
  readonly label: string;
381
381
  onTap(): void;
382
382
  } | null;
383
+ howTo?: {
384
+ readonly line: string;
385
+ onTap(): void;
386
+ } | null;
383
387
  hidden?: readonly StatusChipId[];
384
388
  onHide?(id: StatusChipId): void;
385
389
  onShown?(ids: readonly StatusChipId[]): void;
@@ -413,6 +417,7 @@ export interface VibeMenuProps {
413
417
  settledAtMount?: boolean;
414
418
  switchHiddenAtMount?: boolean;
415
419
  openingKey?: number;
420
+ logOpenOnOpening?: boolean;
416
421
  labeledMenu?: LabeledMenuVariant;
417
422
  onFirstBuildNote?: (action: FirstBuildNoteAction) => void;
418
423
  firstBuildWaitClaim?: ReactNode;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibes.diy/base",
3
- "version": "14.3.453",
3
+ "version": "14.3.454",
4
4
  "license": "SEE LICENSE IN LICENSE.md",
5
5
  "type": "module",
6
6
  "main": "./index.js",
@@ -10,10 +10,10 @@
10
10
  "dependencies": {
11
11
  "@adviser/cement": "~0.5.37",
12
12
  "@emotion/css": "~11.13.5",
13
- "@vibes.diy/api-types": "14.3.453",
14
- "@vibes.diy/use-vibes-types": "14.3.453",
15
- "@vibes.diy/vibe-runtime": "14.3.453",
16
- "@vibes.diy/vibe-types": "14.3.453",
13
+ "@vibes.diy/api-types": "14.3.454",
14
+ "@vibes.diy/use-vibes-types": "14.3.454",
15
+ "@vibes.diy/vibe-runtime": "14.3.454",
16
+ "@vibes.diy/vibe-types": "14.3.454",
17
17
  "arktype": "~2.2.10",
18
18
  "officeparser": "~8.9.0",
19
19
  "qrcode-generator": "~2.0.4",