@agent-native/core 0.76.11 → 0.76.13

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 (58) hide show
  1. package/corpus/README.md +2 -2
  2. package/corpus/core/CHANGELOG.md +19 -0
  3. package/corpus/core/package.json +1 -1
  4. package/corpus/core/src/agent/production-agent.ts +7 -4
  5. package/corpus/core/src/client/FeedbackButton.tsx +162 -18
  6. package/corpus/core/src/client/blocks/library/AnnotatedCodeBlock.tsx +11 -2
  7. package/corpus/core/src/client/blocks/library/ApiEndpointBlock.tsx +46 -19
  8. package/corpus/core/src/client/blocks/library/MermaidBlock.tsx +7 -5
  9. package/corpus/core/src/client/blocks/library/block-copy.ts +367 -0
  10. package/corpus/core/src/client/blocks/library/diagram.tsx +8 -6
  11. package/corpus/core/src/client/blocks/library/wireframe.tsx +7 -2
  12. package/corpus/core/src/client/i18n.tsx +4 -0
  13. package/corpus/templates/clips/app/components/recorder/camera-visualizer.tsx +88 -10
  14. package/corpus/templates/clips/app/components/recorder/pre-record-panel.tsx +64 -0
  15. package/corpus/templates/clips/app/components/recorder/recorder-engine.ts +94 -9
  16. package/corpus/templates/clips/app/lib/camera-blur.ts +341 -0
  17. package/corpus/templates/clips/app/lib/camera-composite.ts +6 -1
  18. package/corpus/templates/clips/app/lib/recorder-preferences.ts +15 -0
  19. package/corpus/templates/clips/app/routes/record.tsx +13 -0
  20. package/corpus/templates/clips/desktop/src/app.tsx +101 -69
  21. package/corpus/templates/clips/desktop/src/lib/voice-dictation.ts +109 -11
  22. package/corpus/templates/clips/desktop/src/styles.css +19 -4
  23. package/corpus/templates/clips/desktop/src-tauri/Cargo.toml +1 -1
  24. package/corpus/templates/clips/desktop/src-tauri/src/native_speech.rs +143 -86
  25. package/corpus/templates/clips/package.json +1 -0
  26. package/corpus/templates/clips/vite.config.ts +38 -1
  27. package/corpus/templates/mail/app/root.tsx +90 -6
  28. package/dist/agent/production-agent.d.ts +7 -4
  29. package/dist/agent/production-agent.d.ts.map +1 -1
  30. package/dist/agent/production-agent.js +7 -4
  31. package/dist/agent/production-agent.js.map +1 -1
  32. package/dist/client/FeedbackButton.d.ts.map +1 -1
  33. package/dist/client/FeedbackButton.js +142 -14
  34. package/dist/client/FeedbackButton.js.map +1 -1
  35. package/dist/client/blocks/library/AnnotatedCodeBlock.d.ts.map +1 -1
  36. package/dist/client/blocks/library/AnnotatedCodeBlock.js +6 -2
  37. package/dist/client/blocks/library/AnnotatedCodeBlock.js.map +1 -1
  38. package/dist/client/blocks/library/ApiEndpointBlock.d.ts.map +1 -1
  39. package/dist/client/blocks/library/ApiEndpointBlock.js +14 -6
  40. package/dist/client/blocks/library/ApiEndpointBlock.js.map +1 -1
  41. package/dist/client/blocks/library/MermaidBlock.d.ts.map +1 -1
  42. package/dist/client/blocks/library/MermaidBlock.js +6 -4
  43. package/dist/client/blocks/library/MermaidBlock.js.map +1 -1
  44. package/dist/client/blocks/library/block-copy.d.ts +33 -0
  45. package/dist/client/blocks/library/block-copy.d.ts.map +1 -0
  46. package/dist/client/blocks/library/block-copy.js +329 -0
  47. package/dist/client/blocks/library/block-copy.js.map +1 -0
  48. package/dist/client/blocks/library/diagram.d.ts.map +1 -1
  49. package/dist/client/blocks/library/diagram.js +7 -5
  50. package/dist/client/blocks/library/diagram.js.map +1 -1
  51. package/dist/client/blocks/library/wireframe.d.ts.map +1 -1
  52. package/dist/client/blocks/library/wireframe.js +4 -2
  53. package/dist/client/blocks/library/wireframe.js.map +1 -1
  54. package/dist/client/i18n.d.ts +1 -0
  55. package/dist/client/i18n.d.ts.map +1 -1
  56. package/dist/client/i18n.js +3 -0
  57. package/dist/client/i18n.js.map +1 -1
  58. package/package.json +1 -1
@@ -0,0 +1,367 @@
1
+ import { useOptionalLocale } from "../../i18n.js";
2
+ import {
3
+ DEFAULT_LOCALE,
4
+ type LocaleCode,
5
+ } from "../../../localization/shared.js";
6
+
7
+ const BLOCK_COPY: Record<
8
+ LocaleCode,
9
+ {
10
+ added: string;
11
+ modified: string;
12
+ removed: string;
13
+ renamed: string;
14
+ deprecated: string;
15
+ requiresAuthentication: string;
16
+ auth: string;
17
+ parameters: string;
18
+ name: string;
19
+ in: string;
20
+ type: string;
21
+ requiredColumn: string;
22
+ description: string;
23
+ required: string;
24
+ optional: string;
25
+ requestBody: string;
26
+ responses: string;
27
+ expandDiagram: string;
28
+ loadingDiagram: string;
29
+ couldNotRenderDiagram: string;
30
+ addDiagramDefinition: string;
31
+ switchToCleanDiagrams: string;
32
+ switchToHandDrawnDiagrams: string;
33
+ cleanDiagramsSwitch: string;
34
+ handDrawnDiagramsSwitch: string;
35
+ clean: string;
36
+ sketchy: string;
37
+ switchVisualStyle: string;
38
+ lineAnnotation: string;
39
+ hiddenLinesExpand: string;
40
+ }
41
+ > = {
42
+ "en-US": {
43
+ added: "Added",
44
+ modified: "Modified",
45
+ removed: "Removed",
46
+ renamed: "Renamed",
47
+ deprecated: "Deprecated",
48
+ requiresAuthentication: "Requires authentication",
49
+ auth: "Auth",
50
+ parameters: "Parameters",
51
+ name: "Name",
52
+ in: "In",
53
+ type: "Type",
54
+ requiredColumn: "Required",
55
+ description: "Description",
56
+ required: "required",
57
+ optional: "optional",
58
+ requestBody: "Request body",
59
+ responses: "Responses",
60
+ expandDiagram: "Expand diagram",
61
+ loadingDiagram: "Loading diagram...",
62
+ couldNotRenderDiagram: "Could not render diagram",
63
+ addDiagramDefinition: "Add a diagram definition to render it.",
64
+ switchToCleanDiagrams: "Switch to clean diagrams",
65
+ switchToHandDrawnDiagrams: "Switch to hand-drawn diagrams",
66
+ cleanDiagramsSwitch: "Clean diagrams - switch to hand-drawn",
67
+ handDrawnDiagramsSwitch: "Hand-drawn diagrams - switch to clean",
68
+ clean: "Clean",
69
+ sketchy: "Sketchy",
70
+ switchVisualStyle: "Switch to {{style}} visual style",
71
+ lineAnnotation: "Line {{line}} annotation",
72
+ hiddenLinesExpand: "{{count}} lines - click to expand",
73
+ },
74
+ "zh-CN": {
75
+ added: "已添加",
76
+ modified: "已修改",
77
+ removed: "已移除",
78
+ renamed: "已重命名",
79
+ deprecated: "已弃用",
80
+ requiresAuthentication: "需要身份验证",
81
+ auth: "身份验证",
82
+ parameters: "参数",
83
+ name: "名称",
84
+ in: "位置",
85
+ type: "类型",
86
+ requiredColumn: "必填",
87
+ description: "描述",
88
+ required: "必填",
89
+ optional: "可选",
90
+ requestBody: "请求体",
91
+ responses: "响应",
92
+ expandDiagram: "展开图表",
93
+ loadingDiagram: "正在加载图表...",
94
+ couldNotRenderDiagram: "无法渲染图表",
95
+ addDiagramDefinition: "添加图表定义以渲染。",
96
+ switchToCleanDiagrams: "切换到简洁图表",
97
+ switchToHandDrawnDiagrams: "切换到手绘图表",
98
+ cleanDiagramsSwitch: "简洁图表 - 切换到手绘",
99
+ handDrawnDiagramsSwitch: "手绘图表 - 切换到简洁",
100
+ clean: "简洁",
101
+ sketchy: "手绘",
102
+ switchVisualStyle: "切换到{{style}}视觉样式",
103
+ lineAnnotation: "第 {{line}} 行注释",
104
+ hiddenLinesExpand: "{{count}} 行 - 点击展开",
105
+ },
106
+ "es-ES": {
107
+ added: "Añadido",
108
+ modified: "Modificado",
109
+ removed: "Eliminado",
110
+ renamed: "Renombrado",
111
+ deprecated: "Obsoleto",
112
+ requiresAuthentication: "Requiere autenticación",
113
+ auth: "Autenticación",
114
+ parameters: "Parámetros",
115
+ name: "Nombre",
116
+ in: "En",
117
+ type: "Tipo",
118
+ requiredColumn: "Obligatorio",
119
+ description: "Descripción",
120
+ required: "obligatorio",
121
+ optional: "opcional",
122
+ requestBody: "Cuerpo de la solicitud",
123
+ responses: "Respuestas",
124
+ expandDiagram: "Ampliar diagrama",
125
+ loadingDiagram: "Cargando diagrama...",
126
+ couldNotRenderDiagram: "No se pudo renderizar el diagrama",
127
+ addDiagramDefinition: "Añade una definición para renderizarlo.",
128
+ switchToCleanDiagrams: "Cambiar a diagramas limpios",
129
+ switchToHandDrawnDiagrams: "Cambiar a diagramas dibujados",
130
+ cleanDiagramsSwitch: "Diagramas limpios - cambiar a dibujados",
131
+ handDrawnDiagramsSwitch: "Diagramas dibujados - cambiar a limpios",
132
+ clean: "Limpio",
133
+ sketchy: "Boceto",
134
+ switchVisualStyle: "Cambiar al estilo visual {{style}}",
135
+ lineAnnotation: "Anotación de la línea {{line}}",
136
+ hiddenLinesExpand: "{{count}} líneas - clic para expandir",
137
+ },
138
+ "fr-FR": {
139
+ added: "Ajouté",
140
+ modified: "Modifié",
141
+ removed: "Supprimé",
142
+ renamed: "Renommé",
143
+ deprecated: "Obsolète",
144
+ requiresAuthentication: "Authentification requise",
145
+ auth: "Auth",
146
+ parameters: "Paramètres",
147
+ name: "Nom",
148
+ in: "Dans",
149
+ type: "Type",
150
+ requiredColumn: "Requis",
151
+ description: "Description",
152
+ required: "requis",
153
+ optional: "facultatif",
154
+ requestBody: "Corps de requête",
155
+ responses: "Réponses",
156
+ expandDiagram: "Agrandir le diagramme",
157
+ loadingDiagram: "Chargement du diagramme...",
158
+ couldNotRenderDiagram: "Impossible de rendre le diagramme",
159
+ addDiagramDefinition: "Ajoutez une définition pour le rendre.",
160
+ switchToCleanDiagrams: "Passer aux diagrammes nets",
161
+ switchToHandDrawnDiagrams: "Passer aux diagrammes dessinés",
162
+ cleanDiagramsSwitch: "Diagrammes nets - passer au dessin",
163
+ handDrawnDiagramsSwitch: "Diagrammes dessinés - passer au net",
164
+ clean: "Net",
165
+ sketchy: "Croquis",
166
+ switchVisualStyle: "Passer au style visuel {{style}}",
167
+ lineAnnotation: "Annotation de la ligne {{line}}",
168
+ hiddenLinesExpand: "{{count}} lignes - cliquer pour développer",
169
+ },
170
+ "de-DE": {
171
+ added: "Hinzugefügt",
172
+ modified: "Geändert",
173
+ removed: "Entfernt",
174
+ renamed: "Umbenannt",
175
+ deprecated: "Veraltet",
176
+ requiresAuthentication: "Authentifizierung erforderlich",
177
+ auth: "Auth",
178
+ parameters: "Parameter",
179
+ name: "Name",
180
+ in: "In",
181
+ type: "Typ",
182
+ requiredColumn: "Erforderlich",
183
+ description: "Beschreibung",
184
+ required: "erforderlich",
185
+ optional: "optional",
186
+ requestBody: "Anfragetext",
187
+ responses: "Antworten",
188
+ expandDiagram: "Diagramm vergrößern",
189
+ loadingDiagram: "Diagramm wird geladen...",
190
+ couldNotRenderDiagram: "Diagramm konnte nicht gerendert werden",
191
+ addDiagramDefinition: "Füge eine Diagrammdefinition hinzu.",
192
+ switchToCleanDiagrams: "Zu klaren Diagrammen wechseln",
193
+ switchToHandDrawnDiagrams: "Zu handgezeichneten Diagrammen wechseln",
194
+ cleanDiagramsSwitch: "Klare Diagramme - zu handgezeichnet wechseln",
195
+ handDrawnDiagramsSwitch: "Handgezeichnet - zu klar wechseln",
196
+ clean: "Klar",
197
+ sketchy: "Skizze",
198
+ switchVisualStyle: "Zum visuellen Stil {{style}} wechseln",
199
+ lineAnnotation: "Annotation für Zeile {{line}}",
200
+ hiddenLinesExpand: "{{count}} Zeilen - zum Erweitern klicken",
201
+ },
202
+ "ja-JP": {
203
+ added: "追加",
204
+ modified: "変更",
205
+ removed: "削除",
206
+ renamed: "名前変更",
207
+ deprecated: "非推奨",
208
+ requiresAuthentication: "認証が必要です",
209
+ auth: "認証",
210
+ parameters: "パラメーター",
211
+ name: "名前",
212
+ in: "場所",
213
+ type: "型",
214
+ requiredColumn: "必須",
215
+ description: "説明",
216
+ required: "必須",
217
+ optional: "任意",
218
+ requestBody: "リクエスト本文",
219
+ responses: "レスポンス",
220
+ expandDiagram: "図を拡大",
221
+ loadingDiagram: "図を読み込み中...",
222
+ couldNotRenderDiagram: "図を表示できませんでした",
223
+ addDiagramDefinition: "表示する図の定義を追加してください。",
224
+ switchToCleanDiagrams: "クリーン表示に切り替え",
225
+ switchToHandDrawnDiagrams: "手描き表示に切り替え",
226
+ cleanDiagramsSwitch: "クリーン表示 - 手描きに切り替え",
227
+ handDrawnDiagramsSwitch: "手描き表示 - クリーンに切り替え",
228
+ clean: "クリーン",
229
+ sketchy: "手描き",
230
+ switchVisualStyle: "{{style}}表示に切り替え",
231
+ lineAnnotation: "{{line}} 行目の注釈",
232
+ hiddenLinesExpand: "{{count}} 行 - クリックして展開",
233
+ },
234
+ "ko-KR": {
235
+ added: "추가됨",
236
+ modified: "수정됨",
237
+ removed: "제거됨",
238
+ renamed: "이름 변경됨",
239
+ deprecated: "사용 중단됨",
240
+ requiresAuthentication: "인증 필요",
241
+ auth: "인증",
242
+ parameters: "매개변수",
243
+ name: "이름",
244
+ in: "위치",
245
+ type: "유형",
246
+ requiredColumn: "필수",
247
+ description: "설명",
248
+ required: "필수",
249
+ optional: "선택",
250
+ requestBody: "요청 본문",
251
+ responses: "응답",
252
+ expandDiagram: "다이어그램 확대",
253
+ loadingDiagram: "다이어그램 로드 중...",
254
+ couldNotRenderDiagram: "다이어그램을 렌더링할 수 없음",
255
+ addDiagramDefinition: "렌더링할 다이어그램 정의를 추가하세요.",
256
+ switchToCleanDiagrams: "깔끔한 다이어그램으로 전환",
257
+ switchToHandDrawnDiagrams: "손그림 다이어그램으로 전환",
258
+ cleanDiagramsSwitch: "깔끔한 다이어그램 - 손그림으로 전환",
259
+ handDrawnDiagramsSwitch: "손그림 다이어그램 - 깔끔하게 전환",
260
+ clean: "깔끔함",
261
+ sketchy: "손그림",
262
+ switchVisualStyle: "{{style}} 시각 스타일로 전환",
263
+ lineAnnotation: "{{line}}번 줄 주석",
264
+ hiddenLinesExpand: "{{count}}줄 - 클릭하여 펼치기",
265
+ },
266
+ "pt-BR": {
267
+ added: "Adicionado",
268
+ modified: "Modificado",
269
+ removed: "Removido",
270
+ renamed: "Renomeado",
271
+ deprecated: "Obsoleto",
272
+ requiresAuthentication: "Requer autenticação",
273
+ auth: "Autenticação",
274
+ parameters: "Parâmetros",
275
+ name: "Nome",
276
+ in: "Em",
277
+ type: "Tipo",
278
+ requiredColumn: "Obrigatório",
279
+ description: "Descrição",
280
+ required: "obrigatório",
281
+ optional: "opcional",
282
+ requestBody: "Corpo da requisição",
283
+ responses: "Respostas",
284
+ expandDiagram: "Expandir diagrama",
285
+ loadingDiagram: "Carregando diagrama...",
286
+ couldNotRenderDiagram: "Não foi possível renderizar o diagrama",
287
+ addDiagramDefinition: "Adicione uma definição para renderizar.",
288
+ switchToCleanDiagrams: "Alternar para diagramas limpos",
289
+ switchToHandDrawnDiagrams: "Alternar para diagramas desenhados",
290
+ cleanDiagramsSwitch: "Diagramas limpos - alternar para desenhados",
291
+ handDrawnDiagramsSwitch: "Diagramas desenhados - alternar para limpos",
292
+ clean: "Limpo",
293
+ sketchy: "Esboço",
294
+ switchVisualStyle: "Alternar para o estilo visual {{style}}",
295
+ lineAnnotation: "Anotação da linha {{line}}",
296
+ hiddenLinesExpand: "{{count}} linhas - clique para expandir",
297
+ },
298
+ "hi-IN": {
299
+ added: "जोड़ा गया",
300
+ modified: "बदला गया",
301
+ removed: "हटाया गया",
302
+ renamed: "नाम बदला गया",
303
+ deprecated: "अप्रचलित",
304
+ requiresAuthentication: "प्रमाणीकरण आवश्यक",
305
+ auth: "प्रमाणीकरण",
306
+ parameters: "पैरामीटर",
307
+ name: "नाम",
308
+ in: "स्थान",
309
+ type: "प्रकार",
310
+ requiredColumn: "आवश्यक",
311
+ description: "विवरण",
312
+ required: "आवश्यक",
313
+ optional: "वैकल्पिक",
314
+ requestBody: "अनुरोध बॉडी",
315
+ responses: "प्रतिक्रियाएँ",
316
+ expandDiagram: "डायग्राम बड़ा करें",
317
+ loadingDiagram: "डायग्राम लोड हो रहा है...",
318
+ couldNotRenderDiagram: "डायग्राम रेंडर नहीं हो सका",
319
+ addDiagramDefinition: "रेंडर करने के लिए डायग्राम परिभाषा जोड़ें।",
320
+ switchToCleanDiagrams: "साफ़ डायग्राम पर स्विच करें",
321
+ switchToHandDrawnDiagrams: "हाथ से बने डायग्राम पर स्विच करें",
322
+ cleanDiagramsSwitch: "साफ़ डायग्राम - हाथ से बने पर स्विच करें",
323
+ handDrawnDiagramsSwitch: "हाथ से बने डायग्राम - साफ़ पर स्विच करें",
324
+ clean: "साफ़",
325
+ sketchy: "स्केच",
326
+ switchVisualStyle: "{{style}} दृश्य शैली पर स्विच करें",
327
+ lineAnnotation: "लाइन {{line}} एनोटेशन",
328
+ hiddenLinesExpand: "{{count}} लाइनें - विस्तार के लिए क्लिक करें",
329
+ },
330
+ "ar-SA": {
331
+ added: "مضاف",
332
+ modified: "معدل",
333
+ removed: "محذوف",
334
+ renamed: "أعيدت تسميته",
335
+ deprecated: "مهمل",
336
+ requiresAuthentication: "يتطلب المصادقة",
337
+ auth: "المصادقة",
338
+ parameters: "المعاملات",
339
+ name: "الاسم",
340
+ in: "في",
341
+ type: "النوع",
342
+ requiredColumn: "مطلوب",
343
+ description: "الوصف",
344
+ required: "مطلوب",
345
+ optional: "اختياري",
346
+ requestBody: "نص الطلب",
347
+ responses: "الاستجابات",
348
+ expandDiagram: "توسيع الرسم",
349
+ loadingDiagram: "جار تحميل الرسم...",
350
+ couldNotRenderDiagram: "تعذر عرض الرسم",
351
+ addDiagramDefinition: "أضف تعريف رسم لعرضه.",
352
+ switchToCleanDiagrams: "التبديل إلى رسوم نظيفة",
353
+ switchToHandDrawnDiagrams: "التبديل إلى رسوم مرسومة يدويا",
354
+ cleanDiagramsSwitch: "رسوم نظيفة - التبديل إلى مرسومة يدويا",
355
+ handDrawnDiagramsSwitch: "رسوم مرسومة يدويا - التبديل إلى نظيفة",
356
+ clean: "نظيف",
357
+ sketchy: "مرسوم",
358
+ switchVisualStyle: "التبديل إلى نمط {{style}} المرئي",
359
+ lineAnnotation: "تعليق السطر {{line}}",
360
+ hiddenLinesExpand: "{{count}} أسطر - انقر للتوسيع",
361
+ },
362
+ };
363
+
364
+ export function useBlockCopy() {
365
+ const locale = useOptionalLocale()?.locale ?? DEFAULT_LOCALE;
366
+ return BLOCK_COPY[locale] ?? BLOCK_COPY[DEFAULT_LOCALE];
367
+ }
@@ -31,6 +31,7 @@ import {
31
31
  sanitizeWireframeCss,
32
32
  scopeDesignCss,
33
33
  } from "./sanitize-html.js";
34
+ import { useBlockCopy } from "./block-copy.js";
34
35
  import {
35
36
  diagramMdx,
36
37
  diagramSchema,
@@ -626,13 +627,14 @@ function ExpandableDiagramBody({
626
627
  const [expanded, setExpanded] = useState(false);
627
628
  const supportsStyleToggle = Boolean(data.html);
628
629
  const style = useWireframeStyle();
630
+ const copy = useBlockCopy();
629
631
  const sketchy = style === "sketchy";
630
632
  const styleLabel = sketchy
631
- ? "Switch to clean diagrams"
632
- : "Switch to hand-drawn diagrams";
633
+ ? copy.switchToCleanDiagrams
634
+ : copy.switchToHandDrawnDiagrams;
633
635
  const styleTooltip = sketchy
634
- ? "Hand-drawn diagrams - switch to clean"
635
- : "Clean diagrams - switch to hand-drawn";
636
+ ? copy.handDrawnDiagramsSwitch
637
+ : copy.cleanDiagramsSwitch;
636
638
  return (
637
639
  <div className="group/diagram relative">
638
640
  <DiagramBody data={data} ctx={ctx} compact={compact} />
@@ -665,13 +667,13 @@ function ExpandableDiagramBody({
665
667
  type="button"
666
668
  data-plan-interactive
667
669
  onClick={() => setExpanded(true)}
668
- aria-label="Expand diagram"
670
+ aria-label={copy.expandDiagram}
669
671
  className="an-diagram-expand-trigger flex size-7 items-center justify-center rounded-md border border-border/60 bg-background/90 text-muted-foreground opacity-0 shadow-sm backdrop-blur transition-[color,opacity] hover:text-foreground focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring group-hover/diagram:opacity-100"
670
672
  >
671
673
  <IconArrowsMaximize className="size-4" />
672
674
  </button>
673
675
  </TooltipTrigger>
674
- <TooltipContent side="left">Expand diagram</TooltipContent>
676
+ <TooltipContent side="left">{copy.expandDiagram}</TooltipContent>
675
677
  </Tooltip>
676
678
  </div>
677
679
  </TooltipProvider>
@@ -35,6 +35,7 @@ import {
35
35
  sanitizeWireframeHtml,
36
36
  scopeDesignCss,
37
37
  } from "./sanitize-html.js";
38
+ import { useBlockCopy } from "./block-copy.js";
38
39
  import { renderWireframeIconHtml } from "./wireframe-icons.js";
39
40
 
40
41
  /**
@@ -291,9 +292,13 @@ function ArtboardFrame({
291
292
 
292
293
  function WireframeStyleToggleButton() {
293
294
  const style = useWireframeStyle();
295
+ const copy = useBlockCopy();
294
296
  const nextStyle = style === "sketchy" ? "clean" : "sketchy";
295
- const label = nextStyle === "clean" ? "Clean" : "Sketchy";
296
- const description = `Switch to ${label.toLowerCase()} visual style`;
297
+ const label = nextStyle === "clean" ? copy.clean : copy.sketchy;
298
+ const description = copy.switchVisualStyle.replace(
299
+ "{{style}}",
300
+ label.toLocaleLowerCase(),
301
+ );
297
302
 
298
303
  return (
299
304
  <button
@@ -464,6 +464,10 @@ export function useLocale(): LocaleContextValue {
464
464
  return value;
465
465
  }
466
466
 
467
+ export function useOptionalLocale(): LocaleContextValue | null {
468
+ return useContext(LocaleContext);
469
+ }
470
+
467
471
  const CORE_FALLBACK_MESSAGES: Record<string, string> = {
468
472
  "runsTray.runs": "Runs",
469
473
  "runsTray.agentRuns": "Agent runs",
@@ -2,6 +2,11 @@ import { useCallback, useEffect, useRef, useState } from "react";
2
2
 
3
3
  import { Button } from "@/components/ui/button";
4
4
  import { cn } from "@/lib/utils";
5
+ import {
6
+ createBackgroundBlurStream,
7
+ DEFAULT_BLUR_PX,
8
+ type CameraBlurHandle,
9
+ } from "@/lib/camera-blur";
5
10
  import type { CameraBubbleSize } from "./camera-bubble";
6
11
 
7
12
  export type CameraTestStatus = "idle" | "starting" | "live" | "error";
@@ -10,6 +15,10 @@ export interface CameraVisualizerProps {
10
15
  deviceId: string | null;
11
16
  disabled?: boolean;
12
17
  className?: string;
18
+ /** Mirror the recording's background-blur setting in the live test preview. */
19
+ blur?: boolean;
20
+ /** Background blur radius (px) reflected live in the test preview. */
21
+ blurRadius?: number;
13
22
  size?: CameraBubbleSize;
14
23
  onSizeChange?: (size: CameraBubbleSize) => void;
15
24
  onStatusChange?: (
@@ -119,6 +128,8 @@ export function CameraVisualizer({
119
128
  deviceId,
120
129
  disabled,
121
130
  className,
131
+ blur = false,
132
+ blurRadius = DEFAULT_BLUR_PX,
122
133
  size = "md",
123
134
  onSizeChange,
124
135
  onStatusChange,
@@ -126,8 +137,14 @@ export function CameraVisualizer({
126
137
  }: CameraVisualizerProps) {
127
138
  const videoRef = useRef<HTMLVideoElement | null>(null);
128
139
  const streamRef = useRef<MediaStream | null>(null);
140
+ const blurHandleRef = useRef<CameraBlurHandle | null>(null);
141
+ // Bumped per attachPreview() so a stale segmenter build (blur toggled mid-load)
142
+ // bails instead of clobbering the preview.
143
+ const attachGenRef = useRef(0);
144
+ const blurRadiusRef = useRef(blurRadius);
129
145
  const runIdRef = useRef(0);
130
146
  const previousDeviceIdRef = useRef(deviceId);
147
+ const previousBlurRef = useRef(blur);
131
148
 
132
149
  const [status, setStatus] = useState<CameraTestStatus>("idle");
133
150
  const [error, setError] = useState<string | null>(null);
@@ -144,11 +161,45 @@ export function CameraVisualizer({
144
161
  }, [onPreviewChange]);
145
162
 
146
163
  const stopCurrent = useCallback(() => {
164
+ blurHandleRef.current?.cleanup();
165
+ blurHandleRef.current = null;
147
166
  stopStream(streamRef.current);
148
167
  streamRef.current = null;
149
168
  clearVideo();
150
169
  }, [clearVideo]);
151
170
 
171
+ // Bind the raw camera or its blurred derivative to the <video> per the current
172
+ // `blur` setting, so the preview matches what recording bakes in. Each call
173
+ // claims a generation and bails if a newer attach superseded it during an await.
174
+ const attachPreview = useCallback(async () => {
175
+ const gen = ++attachGenRef.current;
176
+ const raw = streamRef.current;
177
+ const video = videoRef.current;
178
+ if (!raw || !video) return;
179
+
180
+ let display: MediaStream = raw;
181
+ if (blur) {
182
+ blurHandleRef.current?.cleanup();
183
+ blurHandleRef.current = null;
184
+ const handle = await createBackgroundBlurStream(raw, {
185
+ blurPx: blurRadiusRef.current,
186
+ });
187
+ if (gen !== attachGenRef.current || streamRef.current !== raw) {
188
+ handle.cleanup();
189
+ return;
190
+ }
191
+ blurHandleRef.current = handle;
192
+ display = handle.stream;
193
+ } else {
194
+ blurHandleRef.current?.cleanup();
195
+ blurHandleRef.current = null;
196
+ }
197
+
198
+ if (gen !== attachGenRef.current) return;
199
+ if (video.srcObject !== display) video.srcObject = display;
200
+ await video.play().catch(() => {});
201
+ }, [blur]);
202
+
152
203
  const stopTest = useCallback(() => {
153
204
  runIdRef.current += 1;
154
205
  stopCurrent();
@@ -216,12 +267,15 @@ export function CameraVisualizer({
216
267
  }
217
268
 
218
269
  streamRef.current = stream;
219
- const video = videoRef.current;
220
- if (video) {
221
- video.srcObject = stream;
222
- await video.play().catch(() => {});
270
+ // Webcam unplugged mid-test: tear down so the preview + blur pipeline
271
+ // don't keep running frozen. runId guard skips our own stop().
272
+ for (const track of stream.getVideoTracks()) {
273
+ track.addEventListener("ended", () => {
274
+ if (runIdRef.current === runId) stopTest();
275
+ });
223
276
  }
224
- // Re-check after play()'s await so a newer startTest can't be clobbered.
277
+ await attachPreview();
278
+ // Re-check after the async attach so a newer startTest can't be clobbered.
225
279
  if (runIdRef.current !== runId) {
226
280
  stopCurrent();
227
281
  return;
@@ -239,7 +293,15 @@ export function CameraVisualizer({
239
293
  onStatusChange?.("error", { error: message });
240
294
  clearVideo();
241
295
  }
242
- }, [clearVideo, deviceId, disabled, onStatusChange, stopCurrent]);
296
+ }, [
297
+ attachPreview,
298
+ clearVideo,
299
+ deviceId,
300
+ disabled,
301
+ onStatusChange,
302
+ stopCurrent,
303
+ stopTest,
304
+ ]);
243
305
 
244
306
  useEffect(() => {
245
307
  if (disabled) {
@@ -270,10 +332,10 @@ export function CameraVisualizer({
270
332
  useEffect(() => {
271
333
  if (status !== "live" && status !== "starting") return;
272
334
  const video = videoRef.current;
273
- const stream = streamRef.current;
274
- if (!video || !stream) return;
275
- if (video.srcObject !== stream) {
276
- video.srcObject = stream;
335
+ const display = blurHandleRef.current?.stream ?? streamRef.current;
336
+ if (!video || !display) return;
337
+ if (video.srcObject !== display) {
338
+ video.srcObject = display;
277
339
  }
278
340
  const tryPlay = () => {
279
341
  video.play().catch(() => undefined);
@@ -285,6 +347,22 @@ export function CameraVisualizer({
285
347
  };
286
348
  }, [status]);
287
349
 
350
+ // Toggle blur while live: swap the preview source in place (startTest already
351
+ // binds the initial value, so skip mount).
352
+ useEffect(() => {
353
+ if (previousBlurRef.current === blur) return;
354
+ previousBlurRef.current = blur;
355
+ if (status !== "live" && status !== "starting") return;
356
+ if (!streamRef.current) return;
357
+ void attachPreview();
358
+ }, [blur, status, attachPreview]);
359
+
360
+ // Slider drags adjust the live pipeline without rebuilding the segmenter.
361
+ useEffect(() => {
362
+ blurRadiusRef.current = blurRadius;
363
+ blurHandleRef.current?.setBlurPx(blurRadius);
364
+ }, [blurRadius]);
365
+
288
366
  const live = status === "live";
289
367
  const starting = status === "starting";
290
368
  const showBubble = live || starting;