@hanzo/browser-extension 1.9.54 → 1.9.56

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.
@@ -0,0 +1,93 @@
1
+ import React from 'react';
2
+ import type { SearchMode } from '@hanzo/ai';
3
+ import { Button, XStack } from '@hanzo/ui';
4
+
5
+ /**
6
+ * What the composer's toolbar slot holds on this surface: how to ask (mode) and
7
+ * where to look (sources).
8
+ *
9
+ * The composer itself is `@hanzo/ui/chat`. It owns the field, the Enter rule and
10
+ * the send/stop control — the parts every Hanzo surface shares — and hands back
11
+ * one slot for the affordances that are only true here. Modes and sources are
12
+ * exactly that, so this is what is left after the shell took the rest.
13
+ *
14
+ * Presentational: the selection and both effects arrive as props.
15
+ */
16
+
17
+ /** What the composer sends. `chat` goes straight to the model; the rest ground
18
+ * the question on the live web (`SearchMode` is the wire's own vocabulary).
19
+ *
20
+ * `deep` is EXCLUDED rather than absent. The wire still names it — dropping it
21
+ * from `MODES` only stopped it being offered, it stayed a legal `Mode`, so any
22
+ * call site could still hold one and put the retired name back on the surface.
23
+ * Excluding it makes the collapse structural. Derived from `SearchMode` and not
24
+ * restated, so a mode this surface invents is still a type error, and the day
25
+ * the wire drops `deep` this narrows to nothing on its own. */
26
+ export type Mode = Exclude<SearchMode, 'deep'> | 'chat';
27
+
28
+ /** The modes, in the order they read as escalating effort. */
29
+ export const MODES: { id: Mode; label: string; hint: string }[] = [
30
+ { id: 'chat', label: 'Chat', hint: 'Straight to the model' },
31
+ { id: 'search', label: 'Search', hint: 'Fast grounded answer' },
32
+ { id: 'news', label: 'News', hint: 'Recency-biased' },
33
+ // No 'deep'. It was research with the dials up — same system prompt, same
34
+ // models, same gate — so two names offered a choice that was really an
35
+ // intensity, and hid a 2x price behind an adjective. Cloud folded them into
36
+ // one research mode (apps/answer/mode.go) that always does the deeper pass;
37
+ // 'deep' still RESOLVES there, so a client that has not shipped this does not
38
+ // 400 — which is why dropping the tab is safe on its own.
39
+ { id: 'research', label: 'Research', hint: 'Plans, reads sources, synthesizes' },
40
+ ];
41
+
42
+ export const SOURCES = ['web', 'news', 'academic', 'github', 'reddit', 'x'];
43
+
44
+ export interface ToolbarProps {
45
+ mode: Mode;
46
+ setMode: (mode: Mode) => void;
47
+ sources: Set<string>;
48
+ toggleSource: (source: string) => void;
49
+ }
50
+
51
+ export function Toolbar({ mode, setMode, sources, toggleSource }: ToolbarProps) {
52
+ return (
53
+ // Wraps rather than overflows: ten controls do not fit one row beside the
54
+ // picker and the send control at a reading measure, and the composer's
55
+ // toolbar row does not wrap for its children.
56
+ <XStack shrink={1} minW={0} items="center" gap="$2" flexWrap="wrap">
57
+ <XStack data-slot="modes" items="center" gap="$1">
58
+ {MODES.map((m) => (
59
+ <Button
60
+ key={m.id}
61
+ data-mode={m.id}
62
+ data-on={mode === m.id ? 'true' : undefined}
63
+ size="sm"
64
+ variant={mode === m.id ? 'secondary' : 'ghost'}
65
+ title={m.hint}
66
+ onPress={() => setMode(m.id)}
67
+ >
68
+ {m.label}
69
+ </Button>
70
+ ))}
71
+ </XStack>
72
+ {/* The container stays in the row whatever the mode: dropping it would
73
+ slide the rest of the toolbar left as soon as Chat is picked. Chat is
74
+ ungrounded, so it offers no sources to pick. */}
75
+ <XStack data-slot="sources" items="center" gap="$1">
76
+ {mode !== 'chat' &&
77
+ SOURCES.map((s) => (
78
+ <Button
79
+ key={s}
80
+ data-source={s}
81
+ data-on={sources.has(s) ? 'true' : undefined}
82
+ size="sm"
83
+ variant={sources.has(s) ? 'secondary' : 'ghost'}
84
+ title={`@${s}`}
85
+ onPress={() => toggleSource(s)}
86
+ >
87
+ @{s}
88
+ </Button>
89
+ ))}
90
+ </XStack>
91
+ </XStack>
92
+ );
93
+ }
package/src/newtab.css CHANGED
@@ -36,7 +36,7 @@ body {
36
36
  background: var(--bg);
37
37
  color: var(--text);
38
38
  font-family:
39
- "Geist Sans",
39
+ "Zen",
40
40
  -apple-system,
41
41
  BlinkMacSystemFont,
42
42
  "SF Pro Text",
@@ -230,23 +230,11 @@ a {
230
230
  padding: 24px;
231
231
  overflow-y: auto;
232
232
  }
233
- .ae-hero-card {
234
- width: 100%;
235
- max-width: 720px;
236
- }
237
233
  .ae-news {
238
234
  width: 100%;
239
235
  max-width: 720px;
240
236
  }
241
237
  .ae-news-head,
242
- .ae-followups-head,
243
- .ae-model-group-label {
244
- font-size: 11px;
245
- text-transform: uppercase;
246
- letter-spacing: 0.08em;
247
- color: var(--text-3);
248
- margin-bottom: 10px;
249
- }
250
238
  .ae-news-grid {
251
239
  display: grid;
252
240
  grid-template-columns: 1fr 1fr;
@@ -275,351 +263,20 @@ a {
275
263
  color: var(--text-3);
276
264
  }
277
265
 
278
- /* ── Input card ──────────────────────────────────────────── */
279
- .ae-card {
280
- background: var(--surface-2);
281
- border: 1px solid var(--border-2);
282
- border-radius: var(--radius);
283
- box-shadow:
284
- 0 8px 40px rgba(0, 0, 0, 0.45),
285
- 0 0 0 1px rgba(255, 255, 255, 0.02);
286
- /* NOT overflow:hidden. The model picker menu is position:absolute inside this
287
- card and opens UPWARD, so a clip here truncates it to the card's box: the
288
- "Search models…" filter, the Auto row and the whole Enso group get cut off
289
- and only the last row plus the plan banner survive — which reads as "the
290
- picker is broken / Enso is missing" rather than as a clipping bug. Nothing
291
- here needs clipping: .ae-input is transparent, .ae-card-row has no
292
- background, and the chips/modes/send button carry their own radii and sit
293
- inside the padding, so none of them paint into the rounded corners. */
294
- overflow: visible;
295
- }
296
- .ae-input {
297
- display: block;
298
- width: 100%;
299
- resize: none;
300
- padding: 16px 18px 6px;
301
- min-height: 30px;
302
- max-height: 200px;
303
- background: transparent;
304
- border: none;
305
- outline: none;
306
- color: var(--text);
307
- font-family: inherit;
308
- font-size: 15px;
309
- line-height: 1.5;
310
- }
311
- .ae-input::placeholder {
312
- color: var(--text-3);
313
- }
314
- /* The composer field is @hanzo/ui's Textarea (data-slot is the design system's
315
- own marker). It auto-grows by line count, so the browser's manual resize
316
- grip is noise inside the card. */
317
- .ae-card textarea[data-slot="textarea"] {
318
- resize: none;
319
- }
320
- .ae-card-row {
321
- display: flex;
322
- align-items: center;
323
- justify-content: space-between;
324
- gap: 8px;
325
- padding: 8px 10px 10px;
326
- flex-wrap: wrap;
327
- }
328
- .ae-chips {
329
- display: flex;
330
- gap: 4px;
331
- flex-wrap: wrap;
332
- }
333
- .ae-chip {
334
- padding: 4px 9px;
335
- border-radius: 999px;
336
- cursor: pointer;
337
- background: var(--glass);
338
- border: 1px solid var(--border);
339
- color: var(--text-3);
340
- font-size: 11px;
341
- font-family: inherit;
342
- }
343
- .ae-chip:hover {
344
- color: var(--text-2);
345
- background: var(--surface-2);
346
- }
347
- /* Selected is a step UP the surface ladder, not a white lozenge (chat ModeChips). */
348
- .ae-chip.on {
349
- background: var(--surface-active);
350
- color: var(--text);
351
- border-color: transparent;
352
- font-weight: 500;
353
- }
354
- .ae-card-right {
355
- display: flex;
356
- align-items: center;
357
- gap: 6px;
358
- }
359
- .ae-modes {
360
- display: flex;
361
- gap: 2px;
362
- background: var(--glass);
363
- border-radius: var(--radius-xs);
364
- padding: 2px;
365
- }
366
- .ae-mode {
367
- padding: 4px 9px;
368
- border: none;
369
- background: none;
370
- cursor: pointer;
371
- color: var(--text-3);
372
- font-size: 11.5px;
373
- font-family: inherit;
374
- border-radius: 5px;
375
- }
376
- .ae-mode:hover {
377
- color: var(--text-2);
378
- }
379
- .ae-mode.on {
380
- background: var(--surface-active);
381
- color: var(--text);
382
- font-weight: 500;
383
- }
384
- .ae-send {
385
- width: 34px;
386
- height: 34px;
387
- flex-shrink: 0;
388
- cursor: pointer;
389
- display: flex;
390
- align-items: center;
391
- justify-content: center;
392
- background: var(--text);
393
- color: #000;
394
- border: none;
395
- border-radius: 50%;
396
- }
397
- .ae-send:disabled {
398
- opacity: 0.4;
399
- cursor: default;
400
- }
401
-
402
- /* ── Model picker ────────────────────────────────────────── */
403
- .ae-picker {
404
- position: relative;
405
- }
406
- .ae-picker-btn {
407
- display: flex;
408
- align-items: center;
409
- gap: 6px;
410
- cursor: pointer;
411
- padding: 6px 10px;
412
- background: var(--glass);
413
- border: 1px solid var(--border);
414
- border-radius: var(--radius-xs);
415
- color: var(--text-2);
416
- font-size: 12px;
417
- font-family: inherit;
418
- }
419
- .ae-picker-btn:hover {
420
- color: var(--text);
421
- border-color: var(--border-2);
422
- }
423
- .ae-dot {
424
- width: 6px;
425
- height: 6px;
426
- border-radius: 50%;
427
- background: var(--text-2);
428
- }
429
- .ae-picker-menu {
430
- position: absolute;
431
- bottom: calc(100% + 6px);
432
- right: 0;
433
- z-index: 40;
434
- width: 320px;
435
- max-height: 420px;
436
- display: flex;
437
- flex-direction: column;
438
- background: var(--surface-2);
439
- border: 1px solid var(--border-2);
440
- border-radius: var(--radius-sm);
441
- box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
442
- overflow: hidden;
443
- }
444
- .ae-picker-filter {
445
- margin: 8px;
446
- padding: 8px 10px;
447
- background: var(--bg);
448
- border: 1px solid var(--border);
449
- border-radius: var(--radius-xs);
450
- color: var(--text);
451
- font-family: inherit;
452
- font-size: 13px;
453
- outline: none;
454
- }
455
- .ae-picker-list {
456
- overflow-y: auto;
457
- padding: 0 6px 6px;
458
- }
459
- .ae-model-group-label {
460
- padding: 8px 8px 4px;
461
- margin: 0;
462
- }
463
- .ae-model-row {
464
- display: flex;
465
- flex-direction: column;
466
- gap: 2px;
467
- width: 100%;
468
- text-align: left;
469
- padding: 8px 10px;
470
- background: none;
471
- border: none;
472
- cursor: pointer;
473
- border-radius: var(--radius-xs);
474
- color: var(--text);
475
- font-family: inherit;
476
- }
477
- .ae-model-row:hover {
478
- background: var(--glass);
479
- }
480
- .ae-model-row.active {
481
- background: var(--glass-2);
482
- }
483
- .ae-model-name {
484
- font-size: 13px;
485
- display: flex;
486
- align-items: center;
487
- gap: 7px;
488
- }
489
- .ae-model-desc {
490
- font-size: 11px;
491
- color: var(--text-3);
492
- line-height: 1.3;
493
- }
494
- .ae-badge {
495
- font-size: 9px;
496
- text-transform: uppercase;
497
- letter-spacing: 0.04em;
498
- padding: 1px 5px;
499
- border-radius: 4px;
500
- background: var(--glass-2);
501
- color: var(--text-2);
502
- }
503
- .ae-plan-banner {
504
- display: flex;
505
- align-items: center;
506
- justify-content: space-between;
507
- gap: 8px;
508
- padding: 10px 12px;
509
- border-top: 1px solid var(--border);
510
- font-size: 11.5px;
511
- color: var(--text-2);
512
- background: var(--surface);
513
- }
514
- .ae-plan-tiers {
515
- display: flex;
516
- gap: 8px;
517
- }
518
- .ae-plan-tier b {
519
- color: var(--text);
520
- }
266
+ /* ── Answer prose ────────────────────────────────────────────
267
+ The turn is `@hanzo/ui/chat` Message; markdown is this surface's own
268
+ pipeline, so this is its stylesheet and the only CSS left for an answer. */
521
269
 
522
- /* ── Answer view ─────────────────────────────────────────── */
523
- .ae-answer-wrap {
524
- flex: 1;
525
- display: flex;
526
- flex-direction: column;
527
- min-height: 0;
528
- }
529
- .ae-answer-scroll {
530
- flex: 1;
531
- overflow-y: auto;
532
- padding: 32px 28px 20px;
533
- }
534
- .ae-answer-scroll > * {
535
- max-width: 760px;
536
- margin-left: auto;
537
- margin-right: auto;
538
- }
539
- .ae-question {
540
- font-size: 26px;
541
- font-weight: 600;
542
- letter-spacing: -0.02em;
543
- margin: 0 0 20px;
544
- }
545
- .ae-sources {
546
- display: flex;
547
- gap: 8px;
548
- overflow-x: auto;
549
- padding-bottom: 16px;
550
- margin-bottom: 8px;
551
- }
552
- /* Source card — chat AnswerView: 160px, number pill first, favicon, host, 3-line title. */
553
- .ae-source {
554
- flex: 0 0 168px;
555
- display: flex;
556
- flex-direction: column;
557
- gap: 6px;
558
- padding: 10px;
559
- border: 1px solid var(--border);
560
- border-radius: var(--radius);
561
- background: var(--surface);
562
- transition: background 0.12s ease;
563
- }
564
- .ae-source:hover {
565
- background: var(--surface-2);
566
- }
567
- .ae-source-head {
568
- display: flex;
569
- align-items: center;
570
- gap: 6px;
571
- }
572
- .ae-source-head img {
573
- border-radius: 3px;
574
- flex-shrink: 0;
575
- }
576
- .ae-source-host {
577
- font-size: 11px;
578
- color: var(--text-2);
579
- flex: 1;
580
- overflow: hidden;
581
- text-overflow: ellipsis;
582
- white-space: nowrap;
583
- }
584
- .ae-source-idx {
585
- flex: 0 0 auto;
586
- width: 16px;
587
- height: 16px;
588
- padding: 0;
589
- border: none;
590
- display: inline-flex;
591
- align-items: center;
592
- justify-content: center;
593
- font-size: 10px;
594
- font-weight: 500;
595
- color: var(--text-2);
596
- background: var(--surface-3);
597
- border-radius: 50%;
598
- }
599
- .ae-source-title {
600
- font-size: 12px;
601
- line-height: 1.35;
270
+ .markdown {
271
+ font-size: 15px;
272
+ line-height: 1.65;
602
273
  color: var(--text);
603
- display: -webkit-box;
604
- -webkit-line-clamp: 3;
605
- -webkit-box-orient: vertical;
606
- overflow: hidden;
607
274
  }
608
275
 
609
- .ae-status {
610
- display: flex;
611
- align-items: center;
612
- gap: 10px;
613
- color: var(--text-2);
614
- font-size: 14px;
615
- padding: 8px 0;
276
+ .markdown > *:last-child {
277
+ margin-bottom: 0;
616
278
  }
617
279
 
618
- .ae-answer.markdown {
619
- font-size: 15px;
620
- line-height: 1.65;
621
- color: var(--text);
622
- }
623
280
  .markdown h2 {
624
281
  font-size: 20px;
625
282
  margin: 22px 0 10px;
@@ -661,81 +318,10 @@ a {
661
318
  padding: 1px 5px;
662
319
  border-radius: 4px;
663
320
  font-size: 0.9em;
664
- font-family: "Geist Mono", ui-monospace, monospace;
665
- }
666
-
667
- .ae-followups {
668
- margin-top: 26px;
669
- border-top: 1px solid var(--border);
670
- padding-top: 16px;
671
- }
672
- .ae-followup {
673
- display: flex;
674
- align-items: center;
675
- justify-content: space-between;
676
- width: 100%;
677
- padding: 12px 4px;
678
- background: none;
679
- border: none;
680
- border-bottom: 1px solid var(--border);
681
- color: var(--text);
682
- font-family: inherit;
683
- font-size: 14px;
684
- text-align: left;
685
- cursor: pointer;
686
- }
687
- .ae-followup:hover {
688
- color: var(--text);
689
- }
690
- .ae-followup:hover .ae-followup-arrow {
691
- color: var(--text);
692
- transform: translateX(2px);
693
- }
694
- .ae-followup-arrow {
695
- color: var(--text-3);
696
- transition: transform 0.12s ease;
697
- }
698
-
699
- .ae-error {
700
- color: var(--text-2);
701
- padding: 12px 14px;
702
- border: 1px solid var(--border);
703
- border-radius: var(--radius-sm);
704
- background: var(--surface);
705
- }
706
- .ae-auth {
707
- display: flex;
708
- flex-direction: column;
709
- align-items: flex-start;
710
- gap: 12px;
711
- padding: 8px 0;
712
- }
713
- .ae-auth p {
714
- margin: 0;
715
- color: var(--text-2);
716
- font-size: 15px;
717
- }
718
-
719
- .ae-answer-composer {
720
- padding: 12px 28px 20px;
721
- border-top: 1px solid var(--border);
722
- background: var(--bg);
723
- }
724
- .ae-answer-composer > .ae-card {
725
- max-width: 760px;
726
- margin: 0 auto;
321
+ font-family: "Zen Mono", ui-monospace, monospace;
727
322
  }
728
323
 
729
324
  /* ── Spinner ─────────────────────────────────────────────── */
730
- .ae-spinner {
731
- width: 14px;
732
- height: 14px;
733
- border-radius: 50%;
734
- display: inline-block;
735
- border: 2px solid var(--border-2);
736
- border-top-color: var(--text);
737
- animation: ae-spin 0.7s linear infinite;
738
- }
739
325
  @keyframes ae-spin {
740
326
  to {
741
327
  transform: rotate(360deg);
@@ -777,51 +363,11 @@ a {
777
363
  justify-content: flex-start;
778
364
  padding-top: 48px;
779
365
  }
780
- .ae-answer-scroll {
781
- padding: 20px 16px 16px;
782
- }
783
- .ae-answer-composer {
784
- padding: 10px 16px 16px;
785
- }
786
- .ae-question {
787
- font-size: 21px;
788
- }
789
- /* Input card: let the control row wrap so the model picker + send stay
790
- reachable at narrow widths (mobile-first). */
791
- .ae-card-row {
792
- flex-direction: column;
793
- align-items: stretch;
794
- gap: 10px;
795
- }
796
- .ae-card-right {
797
- justify-content: space-between;
798
- }
799
- .ae-modes {
800
- flex: 1;
801
- justify-content: space-between;
802
- }
803
- .ae-source {
804
- flex-basis: 150px;
805
- }
806
- }
807
-
808
- /* The fallback escape hatch on the expired-session card. Quiet: it is the
809
- second choice, offered so the surface is never a dead end. */
810
- .ae-fallback-link {
811
- display: inline-block;
812
- margin-top: 12px;
813
- color: var(--text-3);
814
- font-size: 13px;
815
- text-decoration: underline;
816
- text-underline-offset: 3px;
817
- }
818
- .ae-fallback-link:hover {
819
- color: var(--text);
820
366
  }
821
367
 
822
368
  /* ── Generative result widgets ───────────────────────────── */
823
- /* margin-left/right stay AUTO: .ae-answer-scroll > * centres its children at
824
- 760px, and a `margin: 4px 0 18px` shorthand here silently resets those to 0 —
369
+ /* margin-left/right stay AUTO: the thread centres its children at a reading
370
+ measure, and a `margin: 4px 0 18px` shorthand here silently resets those to 0 —
825
371
  the widgets then hugged the left edge while the prose beside them stayed
826
372
  centred. Set only the block margins. */
827
373
  .ae-widgets {
package/src/popup.css CHANGED
@@ -32,7 +32,7 @@
32
32
 
33
33
  body {
34
34
  width: 360px;
35
- font-family: 'Geist Sans', -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', sans-serif;
35
+ font-family: 'Zen', -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', sans-serif;
36
36
  background: var(--bg);
37
37
  color: var(--text);
38
38
  font-size: 13px;
@@ -620,7 +620,7 @@ kbd {
620
620
  background: rgba(255,255,255,0.06);
621
621
  border: 1px solid var(--border);
622
622
  border-radius: 3px;
623
- font-family: 'Geist Mono', 'Menlo', monospace;
623
+ font-family: 'Zen Mono', 'Menlo', monospace;
624
624
  font-size: 10px;
625
625
  }
626
626
 
@@ -0,0 +1,29 @@
1
+ import React from 'react';
2
+ import { YStack } from '@hanzo/ui';
3
+ import { Code } from '@hanzo/ui/chat';
4
+ import { blocks } from './markdown.js';
5
+
6
+ /**
7
+ * An answer's text, as both surfaces render it: prose as HTML, fenced code as
8
+ * the shared `@hanzo/ui/chat` Code block — which is what carries the language
9
+ * label and the copy control.
10
+ *
11
+ * The `markdown` class is the prose stylesheet's hook and the only thing left
12
+ * here that is CSS rather than a token; the pipeline itself is `blocks()`.
13
+ */
14
+ export function Prose({ text }: { text: string }) {
15
+ if (!text) return null;
16
+ return (
17
+ <YStack gap="$3" width="100%">
18
+ {blocks(text).map((b, i) =>
19
+ 'code' in b ? (
20
+ <Code key={i} language={b.lang} value={b.code}>
21
+ {b.code}
22
+ </Code>
23
+ ) : (
24
+ <div key={i} className="markdown" dangerouslySetInnerHTML={{ __html: b.html }} />
25
+ ),
26
+ )}
27
+ </YStack>
28
+ );
29
+ }