@tpitre/story-ui 4.16.7 → 4.16.8

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.
@@ -1 +1 @@
1
- {"version":3,"file":"VoiceCanvas.d.ts","sourceRoot":"","sources":["../../../../templates/StoryUI/voice/VoiceCanvas.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAwE,MAAM,OAAO,CAAC;AAY7F,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oEAAoE;IACpE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yEAAyE;IACzE,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IAC7E,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC;AAED,8EAA8E;AAC9E,MAAM,WAAW,iBAAiB;IAChC,4EAA4E;IAC5E,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAID,eAAO,MAAM,WAAW,4FAowBtB,CAAC"}
1
+ {"version":3,"file":"VoiceCanvas.d.ts","sourceRoot":"","sources":["../../../../templates/StoryUI/voice/VoiceCanvas.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAwE,MAAM,OAAO,CAAC;AAY7F,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oEAAoE;IACpE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yEAAyE;IACzE,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IAC7E,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC;AAED,8EAA8E;AAC9E,MAAM,WAAW,iBAAiB;IAChC,4EAA4E;IAC5E,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAID,eAAO,MAAM,WAAW,4FA+wBtB,CAAC"}
@@ -86,6 +86,13 @@ export const VoiceCanvas = React.forwardRef(function VoiceCanvas({ apiBase, prov
86
86
  }, []);
87
87
  // ── Generate / Edit ───────────────────────────────────────────
88
88
  const sendCanvasRequest = useCallback(async (transcript) => {
89
+ // Reject prompts that are too short to produce useful output.
90
+ // Fragments like "create a" or "please" result in broken code.
91
+ const wordCount = transcript.trim().split(/\s+/).length;
92
+ if (wordCount < 3) {
93
+ setErrorMessage('Say a bit more — describe what you want to build.');
94
+ return;
95
+ }
89
96
  if (abortRef.current)
90
97
  abortRef.current.abort();
91
98
  // Stamp this generation so stale finally blocks from aborted requests
@@ -319,15 +326,18 @@ export const VoiceCanvas = React.forwardRef(function VoiceCanvas({ apiBase, prov
319
326
  clearTimeout(autoSubmitRef.current);
320
327
  autoSubmitRef.current = setTimeout(() => {
321
328
  const prompt = transcript.trim();
322
- if (prompt) {
323
- // Clear the pending transcript BEFORE sending so that stopListening
324
- // (if pressed moments later) doesn't fire a duplicate request.
329
+ // Require at least 3 words to avoid sending fragments like "create a"
330
+ // or "please" that produce bad LLM output. Short pauses mid-thought
331
+ // are common in natural speech the longer delay (3s) gives the user
332
+ // time to continue before auto-submitting.
333
+ const wordCount = prompt.split(/\s+/).length;
334
+ if (prompt && wordCount >= 3) {
325
335
  pendingTranscriptRef.current = '';
326
336
  setPendingTranscript('');
327
337
  sendCanvasRequest(prompt);
328
338
  }
329
339
  autoSubmitRef.current = null;
330
- }, 1200);
340
+ }, 3000);
331
341
  }, [sendCanvasRequest]);
332
342
  // ── Voice: start ───────────────────────────────────────────────
333
343
  const startListening = useCallback(() => {
@@ -124,6 +124,14 @@ function VoiceCanvas({
124
124
  // ── Generate / Edit ───────────────────────────────────────────
125
125
 
126
126
  const sendCanvasRequest = useCallback(async (transcript: string) => {
127
+ // Reject prompts that are too short to produce useful output.
128
+ // Fragments like "create a" or "please" result in broken code.
129
+ const wordCount = transcript.trim().split(/\s+/).length;
130
+ if (wordCount < 3) {
131
+ setErrorMessage('Say a bit more — describe what you want to build.');
132
+ return;
133
+ }
134
+
127
135
  if (abortRef.current) abortRef.current.abort();
128
136
 
129
137
  // Stamp this generation so stale finally blocks from aborted requests
@@ -371,15 +379,18 @@ function VoiceCanvas({
371
379
  if (autoSubmitRef.current) clearTimeout(autoSubmitRef.current);
372
380
  autoSubmitRef.current = setTimeout(() => {
373
381
  const prompt = transcript.trim();
374
- if (prompt) {
375
- // Clear the pending transcript BEFORE sending so that stopListening
376
- // (if pressed moments later) doesn't fire a duplicate request.
382
+ // Require at least 3 words to avoid sending fragments like "create a"
383
+ // or "please" that produce bad LLM output. Short pauses mid-thought
384
+ // are common in natural speech the longer delay (3s) gives the user
385
+ // time to continue before auto-submitting.
386
+ const wordCount = prompt.split(/\s+/).length;
387
+ if (prompt && wordCount >= 3) {
377
388
  pendingTranscriptRef.current = '';
378
389
  setPendingTranscript('');
379
390
  sendCanvasRequest(prompt);
380
391
  }
381
392
  autoSubmitRef.current = null;
382
- }, 1200);
393
+ }, 3000);
383
394
  }, [sendCanvasRequest]);
384
395
 
385
396
  // ── Voice: start ───────────────────────────────────────────────
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tpitre/story-ui",
3
- "version": "4.16.7",
3
+ "version": "4.16.8",
4
4
  "description": "AI-powered Storybook story generator with dynamic component discovery",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -124,6 +124,14 @@ function VoiceCanvas({
124
124
  // ── Generate / Edit ───────────────────────────────────────────
125
125
 
126
126
  const sendCanvasRequest = useCallback(async (transcript: string) => {
127
+ // Reject prompts that are too short to produce useful output.
128
+ // Fragments like "create a" or "please" result in broken code.
129
+ const wordCount = transcript.trim().split(/\s+/).length;
130
+ if (wordCount < 3) {
131
+ setErrorMessage('Say a bit more — describe what you want to build.');
132
+ return;
133
+ }
134
+
127
135
  if (abortRef.current) abortRef.current.abort();
128
136
 
129
137
  // Stamp this generation so stale finally blocks from aborted requests
@@ -371,15 +379,18 @@ function VoiceCanvas({
371
379
  if (autoSubmitRef.current) clearTimeout(autoSubmitRef.current);
372
380
  autoSubmitRef.current = setTimeout(() => {
373
381
  const prompt = transcript.trim();
374
- if (prompt) {
375
- // Clear the pending transcript BEFORE sending so that stopListening
376
- // (if pressed moments later) doesn't fire a duplicate request.
382
+ // Require at least 3 words to avoid sending fragments like "create a"
383
+ // or "please" that produce bad LLM output. Short pauses mid-thought
384
+ // are common in natural speech the longer delay (3s) gives the user
385
+ // time to continue before auto-submitting.
386
+ const wordCount = prompt.split(/\s+/).length;
387
+ if (prompt && wordCount >= 3) {
377
388
  pendingTranscriptRef.current = '';
378
389
  setPendingTranscript('');
379
390
  sendCanvasRequest(prompt);
380
391
  }
381
392
  autoSubmitRef.current = null;
382
- }, 1200);
393
+ }, 3000);
383
394
  }, [sendCanvasRequest]);
384
395
 
385
396
  // ── Voice: start ───────────────────────────────────────────────