@nandoblanco/opencode-local-search 1.0.1 → 1.0.2
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/package.json +1 -1
- package/src/tui.ts +440 -340
package/package.json
CHANGED
package/src/tui.ts
CHANGED
|
@@ -542,117 +542,149 @@ function createTuiRenderer() {
|
|
|
542
542
|
queueMicrotask(applyDialogWidth);
|
|
543
543
|
},
|
|
544
544
|
width: "100%",
|
|
545
|
-
height:
|
|
545
|
+
height: 34,
|
|
546
546
|
flexDirection: "column",
|
|
547
547
|
backgroundColor: () => theme().background.base,
|
|
548
|
+
paddingLeft: 2,
|
|
549
|
+
paddingRight: 2,
|
|
550
|
+
paddingTop: 1,
|
|
551
|
+
paddingBottom: 1,
|
|
552
|
+
gap: 1,
|
|
548
553
|
},
|
|
549
|
-
// 1. Header Bar
|
|
554
|
+
// 1. Header Bar (single-line, no wrapping)
|
|
550
555
|
el(
|
|
551
556
|
"box",
|
|
552
557
|
{
|
|
553
558
|
flexDirection: "row",
|
|
554
559
|
justifyContent: "space-between",
|
|
555
560
|
alignItems: "center",
|
|
556
|
-
|
|
557
|
-
|
|
561
|
+
border: ["bottom"],
|
|
562
|
+
borderColor: () => theme().border.base,
|
|
563
|
+
paddingBottom: 0,
|
|
558
564
|
flexShrink: 0,
|
|
565
|
+
width: "100%",
|
|
559
566
|
},
|
|
560
567
|
el(
|
|
561
568
|
"box",
|
|
562
|
-
{ flexDirection: "row", gap: 2, alignItems: "center" },
|
|
569
|
+
{ flexDirection: "row", gap: 2, alignItems: "center", flexShrink: 0 },
|
|
563
570
|
el(
|
|
564
571
|
"text",
|
|
565
572
|
{
|
|
566
|
-
|
|
573
|
+
wrapMode: "none",
|
|
574
|
+
flexShrink: 0,
|
|
575
|
+
fg: () => theme().text.action.primary.base,
|
|
567
576
|
attributes: TextAttributes.BOLD,
|
|
568
577
|
},
|
|
569
|
-
"
|
|
578
|
+
"opencode / search"
|
|
570
579
|
),
|
|
571
580
|
el(
|
|
572
581
|
"text",
|
|
573
|
-
{
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
582
|
+
{
|
|
583
|
+
wrapMode: "none",
|
|
584
|
+
flexShrink: 0,
|
|
585
|
+
fg: () => theme().text.muted,
|
|
586
|
+
},
|
|
587
|
+
() => props.context.ui.format.path(props.currentDirectory)
|
|
578
588
|
)
|
|
579
589
|
),
|
|
580
590
|
el(
|
|
581
|
-
"
|
|
591
|
+
"text",
|
|
582
592
|
{
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
593
|
+
wrapMode: "none",
|
|
594
|
+
flexShrink: 0,
|
|
595
|
+
fg: () => theme().text.muted,
|
|
586
596
|
},
|
|
587
|
-
|
|
588
|
-
"text",
|
|
589
|
-
{ fg: () => theme().text.muted },
|
|
590
|
-
() => props.context.ui.format.path(props.currentDirectory)
|
|
591
|
-
),
|
|
592
|
-
el(
|
|
593
|
-
"box",
|
|
594
|
-
{
|
|
595
|
-
paddingX: 1,
|
|
596
|
-
onMouseUp: () => props.close(),
|
|
597
|
-
},
|
|
598
|
-
el("text", { fg: () => theme().text.muted }, "esc")
|
|
599
|
-
)
|
|
597
|
+
"[↑↓] select [Enter] open [Tab] pane [Esc] close"
|
|
600
598
|
)
|
|
601
599
|
),
|
|
602
600
|
|
|
603
|
-
// 2.
|
|
601
|
+
// 2. Boxed Filter + Pills Card
|
|
604
602
|
el(
|
|
605
603
|
"box",
|
|
606
604
|
{
|
|
607
605
|
flexDirection: "column",
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
606
|
+
backgroundColor: () =>
|
|
607
|
+
theme().background.raised?.base ?? theme().background.base,
|
|
608
|
+
border: true,
|
|
609
|
+
borderColor: () =>
|
|
610
|
+
focusPane() === "search"
|
|
611
|
+
? theme().text.action.primary.base
|
|
612
|
+
: theme().border.base,
|
|
613
|
+
paddingLeft: 2,
|
|
614
|
+
paddingRight: 2,
|
|
615
|
+
paddingTop: 0,
|
|
616
|
+
paddingBottom: 0,
|
|
617
|
+
gap: 0,
|
|
611
618
|
flexShrink: 0,
|
|
612
|
-
|
|
613
|
-
borderColor: () => theme().border.base,
|
|
619
|
+
width: "100%",
|
|
614
620
|
},
|
|
615
621
|
el(
|
|
616
622
|
"box",
|
|
617
623
|
{
|
|
618
624
|
flexDirection: "row",
|
|
625
|
+
justifyContent: "space-between",
|
|
619
626
|
alignItems: "center",
|
|
620
627
|
gap: 1,
|
|
628
|
+
width: "100%",
|
|
621
629
|
},
|
|
622
630
|
el(
|
|
623
631
|
"text",
|
|
624
632
|
{
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
633
|
+
width: 7,
|
|
634
|
+
wrapMode: "none",
|
|
635
|
+
flexShrink: 0,
|
|
636
|
+
fg: () => theme().text.action.primary.base,
|
|
629
637
|
attributes: TextAttributes.BOLD,
|
|
630
638
|
},
|
|
631
|
-
"
|
|
639
|
+
"Filter:"
|
|
632
640
|
),
|
|
633
|
-
el(
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
}
|
|
641
|
+
el(
|
|
642
|
+
"box",
|
|
643
|
+
{
|
|
644
|
+
flexGrow: 1,
|
|
645
|
+
flexShrink: 1,
|
|
646
|
+
minWidth: 0,
|
|
640
647
|
},
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
648
|
+
el("input", {
|
|
649
|
+
id: "session-search-input",
|
|
650
|
+
width: "100%",
|
|
651
|
+
ref: (r: unknown) => {
|
|
652
|
+
inputRef = r;
|
|
653
|
+
if (props.initialQuery && r && (r as { value?: string }).value !== props.initialQuery) {
|
|
654
|
+
(r as { value: string }).value = props.initialQuery;
|
|
655
|
+
}
|
|
656
|
+
},
|
|
657
|
+
value: () => query(),
|
|
658
|
+
focused: () => focusPane() === "search",
|
|
659
|
+
maxLength: 2000,
|
|
660
|
+
placeholder:
|
|
661
|
+
"Search keywords, \"exact phrase\", /regex/i, ~fuzzy, role:user, date:7d, file:path, tool:name...",
|
|
662
|
+
placeholderColor: () => theme().text.muted,
|
|
663
|
+
textColor: () => theme().text.base,
|
|
664
|
+
focusedTextColor: () => theme().text.formfield.focused,
|
|
665
|
+
cursorColor: () => theme().text.formfield.focused,
|
|
666
|
+
backgroundColor: () =>
|
|
667
|
+
theme().background.raised?.base ?? theme().background.base,
|
|
668
|
+
focusedBackgroundColor: () =>
|
|
669
|
+
theme().background.raised?.base ?? theme().background.base,
|
|
670
|
+
onMouseDown: () => setFocusPane("search"),
|
|
671
|
+
onInput: (val: string) => setQuery(val),
|
|
672
|
+
})
|
|
673
|
+
),
|
|
674
|
+
el(
|
|
675
|
+
"text",
|
|
676
|
+
{
|
|
677
|
+
wrapMode: "none",
|
|
678
|
+
flexShrink: 0,
|
|
679
|
+
fg: () =>
|
|
680
|
+
theme().text.feedback?.success?.base ??
|
|
681
|
+
theme().text.action.primary.base,
|
|
682
|
+
},
|
|
683
|
+
() =>
|
|
684
|
+
loading()
|
|
685
|
+
? "indexing SQLite..."
|
|
686
|
+
: `${results().length} of ${indexData().sessions.length} sessions · 0 tokens`
|
|
687
|
+
)
|
|
656
688
|
),
|
|
657
689
|
// Filter pills bar
|
|
658
690
|
el(
|
|
@@ -728,339 +760,407 @@ function createTuiRenderer() {
|
|
|
728
760
|
)
|
|
729
761
|
),
|
|
730
762
|
|
|
731
|
-
// 3. Split-Pane Main Body
|
|
763
|
+
// 3. Split-Pane Main Body: Two Side-by-Side Bordered Cards
|
|
732
764
|
el(
|
|
733
765
|
"box",
|
|
734
766
|
{
|
|
735
767
|
flexDirection: "row",
|
|
768
|
+
gap: 2,
|
|
736
769
|
flexGrow: 1,
|
|
737
770
|
minHeight: 0,
|
|
771
|
+
width: "100%",
|
|
738
772
|
},
|
|
739
|
-
// Left
|
|
773
|
+
// Left Card: Results List (44% width)
|
|
740
774
|
el(
|
|
741
|
-
"
|
|
775
|
+
"box",
|
|
742
776
|
{
|
|
743
|
-
id: "session-search-list",
|
|
744
|
-
ref: (r: unknown) => {
|
|
745
|
-
listScrollRef = r;
|
|
746
|
-
},
|
|
747
777
|
width: "44%",
|
|
748
778
|
height: "100%",
|
|
779
|
+
flexDirection: "column",
|
|
749
780
|
flexShrink: 0,
|
|
750
|
-
|
|
781
|
+
backgroundColor: () =>
|
|
782
|
+
theme().background.raised?.base ?? theme().background.base,
|
|
783
|
+
border: true,
|
|
751
784
|
borderColor: () =>
|
|
752
|
-
focusPane() === "list"
|
|
753
|
-
|
|
785
|
+
focusPane() === "list"
|
|
786
|
+
? theme().text.action.primary.base
|
|
787
|
+
: theme().border.base,
|
|
788
|
+
paddingLeft: 1,
|
|
789
|
+
paddingRight: 1,
|
|
790
|
+
paddingTop: 0,
|
|
791
|
+
paddingBottom: 0,
|
|
754
792
|
onMouseDown: () => setFocusPane("list"),
|
|
755
793
|
},
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
794
|
+
el(
|
|
795
|
+
"box",
|
|
796
|
+
{
|
|
797
|
+
flexDirection: "row",
|
|
798
|
+
justifyContent: "space-between",
|
|
799
|
+
border: ["bottom"],
|
|
800
|
+
borderColor: () => theme().border.base,
|
|
801
|
+
paddingX: 1,
|
|
802
|
+
flexShrink: 0,
|
|
759
803
|
},
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
804
|
+
el(
|
|
805
|
+
"text",
|
|
806
|
+
{
|
|
807
|
+
fg: () => theme().text.action.primary.base,
|
|
808
|
+
attributes: TextAttributes.BOLD,
|
|
809
|
+
},
|
|
810
|
+
"◈ MATCHING SESSIONS"
|
|
811
|
+
),
|
|
812
|
+
el(
|
|
813
|
+
"text",
|
|
814
|
+
{ fg: () => theme().text.muted },
|
|
815
|
+
() =>
|
|
816
|
+
`${(parsedQuery().scope ?? scope()) === "project" ? "project" : "all"} · ${parsedQuery().effectiveMode}`
|
|
817
|
+
)
|
|
818
|
+
),
|
|
819
|
+
el(
|
|
820
|
+
"scrollbox",
|
|
821
|
+
{
|
|
822
|
+
id: "session-search-list",
|
|
823
|
+
ref: (r: unknown) => {
|
|
824
|
+
listScrollRef = r;
|
|
825
|
+
},
|
|
826
|
+
width: "100%",
|
|
827
|
+
flexGrow: 1,
|
|
828
|
+
minHeight: 0,
|
|
829
|
+
scrollbarOptions: { visible: false },
|
|
775
830
|
},
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
el(
|
|
831
|
+
createComponent(Show, {
|
|
832
|
+
get when() {
|
|
833
|
+
return !loading() && results().length > 0;
|
|
834
|
+
},
|
|
835
|
+
get fallback() {
|
|
836
|
+
return el(
|
|
837
|
+
"box",
|
|
838
|
+
{ paddingX: 1, paddingY: 1 },
|
|
839
|
+
el(
|
|
840
|
+
"text",
|
|
841
|
+
{ fg: () => theme().text.muted },
|
|
842
|
+
() =>
|
|
843
|
+
loading()
|
|
844
|
+
? "Loading sessions..."
|
|
845
|
+
: errorMsg()
|
|
846
|
+
? `Error: ${errorMsg()}`
|
|
847
|
+
: "No matching sessions found. Try ~fuzzy, scope:all, or fewer terms."
|
|
848
|
+
)
|
|
849
|
+
);
|
|
850
|
+
},
|
|
851
|
+
get children() {
|
|
852
|
+
return createComponent(For, {
|
|
853
|
+
get each() {
|
|
854
|
+
return results();
|
|
855
|
+
},
|
|
856
|
+
children: (item: SearchSessionMatch, idx: () => number) => {
|
|
857
|
+
const isSelected = () => selectedIndex() === idx();
|
|
858
|
+
return el(
|
|
805
859
|
"box",
|
|
806
860
|
{
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
861
|
+
id: () => `session-row-${idx()}`,
|
|
862
|
+
flexDirection: "column",
|
|
863
|
+
paddingX: 1,
|
|
864
|
+
paddingY: 0,
|
|
865
|
+
marginBottom: 1,
|
|
866
|
+
flexShrink: 0,
|
|
867
|
+
backgroundColor: () =>
|
|
868
|
+
isSelected()
|
|
869
|
+
? theme().background.action.primary.focused
|
|
870
|
+
: undefined,
|
|
871
|
+
onMouseUp: () => {
|
|
872
|
+
setSelectedIndex(idx());
|
|
873
|
+
openSelected();
|
|
874
|
+
},
|
|
875
|
+
onMouseOver: () => {
|
|
876
|
+
setSelectedIndex(idx());
|
|
877
|
+
},
|
|
810
878
|
},
|
|
811
879
|
el(
|
|
812
|
-
"
|
|
880
|
+
"box",
|
|
813
881
|
{
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
minWidth: 0,
|
|
818
|
-
fg: () =>
|
|
819
|
-
isSelected()
|
|
820
|
-
? theme().text.action.primary.focused
|
|
821
|
-
: theme().text.base,
|
|
822
|
-
attributes: () =>
|
|
823
|
-
isSelected() ? TextAttributes.BOLD : undefined,
|
|
882
|
+
flexDirection: "row",
|
|
883
|
+
justifyContent: "space-between",
|
|
884
|
+
width: "100%",
|
|
824
885
|
},
|
|
825
|
-
(
|
|
826
|
-
|
|
886
|
+
el(
|
|
887
|
+
"text",
|
|
888
|
+
{
|
|
889
|
+
wrapMode: "none",
|
|
890
|
+
truncate: true,
|
|
891
|
+
flexShrink: 1,
|
|
892
|
+
minWidth: 0,
|
|
893
|
+
fg: () =>
|
|
894
|
+
isSelected()
|
|
895
|
+
? theme().text.action.primary.focused
|
|
896
|
+
: theme().text.base,
|
|
897
|
+
attributes: () =>
|
|
898
|
+
isSelected() ? TextAttributes.BOLD : undefined,
|
|
899
|
+
},
|
|
900
|
+
() =>
|
|
901
|
+
`${isSelected() ? "▸ " : " "}${item.session.title}`
|
|
902
|
+
),
|
|
903
|
+
el(
|
|
904
|
+
"text",
|
|
905
|
+
{
|
|
906
|
+
wrapMode: "none",
|
|
907
|
+
flexShrink: 0,
|
|
908
|
+
fg: () =>
|
|
909
|
+
isSelected()
|
|
910
|
+
? theme().text.action.primary.focused
|
|
911
|
+
: theme().text.action.primary.base,
|
|
912
|
+
},
|
|
913
|
+
() =>
|
|
914
|
+
` [${item.matchBadge}] ${formatRelativeTime(item.session.timeUpdated)}`
|
|
915
|
+
)
|
|
827
916
|
),
|
|
828
917
|
el(
|
|
829
918
|
"text",
|
|
830
919
|
{
|
|
831
920
|
wrapMode: "none",
|
|
832
|
-
|
|
921
|
+
truncate: true,
|
|
833
922
|
fg: () =>
|
|
834
923
|
isSelected()
|
|
835
924
|
? theme().text.action.primary.focused
|
|
836
925
|
: theme().text.muted,
|
|
837
926
|
},
|
|
838
|
-
() =>
|
|
839
|
-
` [${item.matchBadge}] ${formatRelativeTime(item.session.timeUpdated)}`
|
|
927
|
+
() => ` ${item.bestSnippet}`
|
|
840
928
|
)
|
|
841
|
-
)
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
fg: () =>
|
|
848
|
-
isSelected()
|
|
849
|
-
? theme().text.action.primary.focused
|
|
850
|
-
: theme().text.muted,
|
|
851
|
-
},
|
|
852
|
-
() => ` ${item.bestSnippet}`
|
|
853
|
-
)
|
|
854
|
-
);
|
|
855
|
-
},
|
|
856
|
-
});
|
|
857
|
-
},
|
|
858
|
-
})
|
|
929
|
+
);
|
|
930
|
+
},
|
|
931
|
+
});
|
|
932
|
+
},
|
|
933
|
+
})
|
|
934
|
+
)
|
|
859
935
|
),
|
|
860
936
|
|
|
861
|
-
// Right
|
|
937
|
+
// Right Card: Rich Match & Session Context Preview (56% width)
|
|
862
938
|
el(
|
|
863
|
-
"
|
|
939
|
+
"box",
|
|
864
940
|
{
|
|
865
|
-
id: "session-search-preview",
|
|
866
|
-
ref: (r: unknown) => {
|
|
867
|
-
previewScrollRef = r;
|
|
868
|
-
},
|
|
869
941
|
flexGrow: 1,
|
|
942
|
+
height: "100%",
|
|
870
943
|
minWidth: 0,
|
|
871
944
|
minHeight: 0,
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
945
|
+
flexDirection: "column",
|
|
946
|
+
backgroundColor: () =>
|
|
947
|
+
theme().background.raised?.base ?? theme().background.base,
|
|
948
|
+
border: true,
|
|
949
|
+
borderColor: () =>
|
|
950
|
+
focusPane() === "preview"
|
|
951
|
+
? theme().text.action.primary.base
|
|
952
|
+
: theme().border.base,
|
|
953
|
+
paddingLeft: 2,
|
|
954
|
+
paddingRight: 2,
|
|
955
|
+
paddingTop: 0,
|
|
956
|
+
paddingBottom: 1,
|
|
875
957
|
onMouseDown: () => setFocusPane("preview"),
|
|
876
958
|
},
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
959
|
+
el(
|
|
960
|
+
"box",
|
|
961
|
+
{
|
|
962
|
+
flexDirection: "row",
|
|
963
|
+
justifyContent: "space-between",
|
|
964
|
+
border: ["bottom"],
|
|
965
|
+
borderColor: () => theme().border.base,
|
|
966
|
+
marginBottom: 1,
|
|
967
|
+
flexShrink: 0,
|
|
880
968
|
},
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
969
|
+
el(
|
|
970
|
+
"text",
|
|
971
|
+
{
|
|
972
|
+
fg: () => theme().text.action.primary.base,
|
|
973
|
+
attributes: TextAttributes.BOLD,
|
|
974
|
+
},
|
|
975
|
+
"◈ CONVERSATION & MATCH PREVIEW"
|
|
976
|
+
),
|
|
977
|
+
el(
|
|
978
|
+
"text",
|
|
979
|
+
{ fg: () => theme().text.muted },
|
|
980
|
+
() =>
|
|
981
|
+
selectedMatch()
|
|
982
|
+
? `${selectedMatch()?.totalMatches ?? 0} match${selectedMatch()?.totalMatches === 1 ? "" : "es"} · updated ${formatRelativeTime(selectedMatch()?.session.timeUpdated ?? 0)}`
|
|
983
|
+
: "no selection"
|
|
984
|
+
)
|
|
985
|
+
),
|
|
986
|
+
el(
|
|
987
|
+
"scrollbox",
|
|
988
|
+
{
|
|
989
|
+
id: "session-search-preview",
|
|
990
|
+
ref: (r: unknown) => {
|
|
991
|
+
previewScrollRef = r;
|
|
992
|
+
},
|
|
993
|
+
flexGrow: 1,
|
|
994
|
+
minWidth: 0,
|
|
995
|
+
minHeight: 0,
|
|
996
|
+
focused: () => focusPane() === "preview",
|
|
887
997
|
},
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
{
|
|
895
|
-
fg: () => theme().text.base,
|
|
896
|
-
attributes: TextAttributes.BOLD,
|
|
897
|
-
},
|
|
898
|
-
() => selectedMatch()?.session.title ?? ""
|
|
899
|
-
),
|
|
900
|
-
el(
|
|
998
|
+
createComponent(Show, {
|
|
999
|
+
get when() {
|
|
1000
|
+
return selectedMatch();
|
|
1001
|
+
},
|
|
1002
|
+
get fallback() {
|
|
1003
|
+
return el(
|
|
901
1004
|
"text",
|
|
902
|
-
{ fg: () => theme().text.muted
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
1005
|
+
{ fg: () => theme().text.muted },
|
|
1006
|
+
"Select a session on the left to inspect matching messages, tools, and files."
|
|
1007
|
+
);
|
|
1008
|
+
},
|
|
1009
|
+
get children() {
|
|
1010
|
+
return el(
|
|
1011
|
+
"box",
|
|
1012
|
+
{ flexDirection: "column", gap: 1 },
|
|
1013
|
+
el(
|
|
1014
|
+
"box",
|
|
1015
|
+
{
|
|
1016
|
+
flexDirection: "column",
|
|
1017
|
+
paddingLeft: 1,
|
|
1018
|
+
border: ["left"],
|
|
1019
|
+
borderColor: () => theme().text.action.primary.base,
|
|
1020
|
+
},
|
|
1021
|
+
el(
|
|
918
1022
|
"text",
|
|
919
|
-
{
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
get when() {
|
|
927
|
-
return (selectedMatch()?.session.files.length ?? 0) > 0;
|
|
928
|
-
},
|
|
929
|
-
get children() {
|
|
930
|
-
return el(
|
|
1023
|
+
{
|
|
1024
|
+
fg: () => theme().text.base,
|
|
1025
|
+
attributes: TextAttributes.BOLD,
|
|
1026
|
+
},
|
|
1027
|
+
() => selectedMatch()?.session.title ?? ""
|
|
1028
|
+
),
|
|
1029
|
+
el(
|
|
931
1030
|
"text",
|
|
932
1031
|
{ fg: () => theme().text.muted, wrapMode: "word" },
|
|
933
|
-
() =>
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
attributes: TextAttributes.BOLD,
|
|
946
|
-
marginTop: 1,
|
|
947
|
-
},
|
|
948
|
-
() =>
|
|
949
|
-
query().trim()
|
|
950
|
-
? `Matching Snippets (${selectedMatch()?.matches.length ?? 0} shown)`
|
|
951
|
-
: "Recent Conversation Preview"
|
|
952
|
-
),
|
|
953
|
-
createComponent(For, {
|
|
954
|
-
get each() {
|
|
955
|
-
return selectedMatch()?.matches ?? [];
|
|
956
|
-
},
|
|
957
|
-
children: (hit: SearchSessionMatch["matches"][number], idx: () => number) => {
|
|
958
|
-
const isActiveSnippet = () => idx() === selectedSnippetIndex();
|
|
959
|
-
return el(
|
|
960
|
-
"box",
|
|
961
|
-
{
|
|
962
|
-
id: () => `snippet-row-${idx()}`,
|
|
963
|
-
flexDirection: "column",
|
|
964
|
-
paddingLeft: 1,
|
|
965
|
-
marginBottom: 1,
|
|
966
|
-
border: ["left"],
|
|
967
|
-
borderColor: () =>
|
|
968
|
-
isActiveSnippet()
|
|
969
|
-
? theme().text.action.primary.base
|
|
970
|
-
: theme().border.base,
|
|
971
|
-
onMouseUp: () => {
|
|
972
|
-
setSelectedSnippetIndex(idx());
|
|
973
|
-
openSelected(hit);
|
|
974
|
-
},
|
|
1032
|
+
() => {
|
|
1033
|
+
const m = selectedMatch();
|
|
1034
|
+
if (!m) return "";
|
|
1035
|
+
const dir = m.session.directory
|
|
1036
|
+
? props.context.ui.format.path(m.session.directory)
|
|
1037
|
+
: "(no directory)";
|
|
1038
|
+
return `${dir} · updated ${formatRelativeTime(m.session.timeUpdated)} · ${m.totalMatches} match${m.totalMatches === 1 ? "" : "es"}`;
|
|
1039
|
+
}
|
|
1040
|
+
),
|
|
1041
|
+
createComponent(Show, {
|
|
1042
|
+
get when() {
|
|
1043
|
+
return (selectedMatch()?.session.tools.length ?? 0) > 0;
|
|
975
1044
|
},
|
|
976
|
-
|
|
977
|
-
|
|
1045
|
+
get children() {
|
|
1046
|
+
return el(
|
|
1047
|
+
"text",
|
|
1048
|
+
{ fg: () => theme().text.muted, wrapMode: "word" },
|
|
1049
|
+
() =>
|
|
1050
|
+
`Tools: ${selectedMatch()?.session.tools.slice(0, 8).join(", ")}`
|
|
1051
|
+
);
|
|
1052
|
+
},
|
|
1053
|
+
}),
|
|
1054
|
+
createComponent(Show, {
|
|
1055
|
+
get when() {
|
|
1056
|
+
return (selectedMatch()?.session.files.length ?? 0) > 0;
|
|
1057
|
+
},
|
|
1058
|
+
get children() {
|
|
1059
|
+
return el(
|
|
1060
|
+
"text",
|
|
1061
|
+
{ fg: () => theme().text.muted, wrapMode: "word" },
|
|
1062
|
+
() =>
|
|
1063
|
+
`Files: ${selectedMatch()
|
|
1064
|
+
?.session.files.slice(0, 4)
|
|
1065
|
+
.map((f: string) => props.context.ui.format.path(f))
|
|
1066
|
+
.join(", ")}${(selectedMatch()?.session.files.length ?? 0) > 4 ? ` (+${(selectedMatch()?.session.files.length ?? 0) - 4} more)` : ""}`
|
|
1067
|
+
);
|
|
1068
|
+
},
|
|
1069
|
+
})
|
|
1070
|
+
),
|
|
1071
|
+
el(
|
|
1072
|
+
"text",
|
|
1073
|
+
{
|
|
1074
|
+
fg: () => theme().text.action.primary.base,
|
|
1075
|
+
attributes: TextAttributes.BOLD,
|
|
1076
|
+
marginTop: 1,
|
|
1077
|
+
},
|
|
1078
|
+
() =>
|
|
1079
|
+
query().trim()
|
|
1080
|
+
? `◈ MATCHING SNIPPETS (${selectedMatch()?.matches.length ?? 0} SHOWN)`
|
|
1081
|
+
: "◈ RECENT CONVERSATION PREVIEW"
|
|
1082
|
+
),
|
|
1083
|
+
createComponent(For, {
|
|
1084
|
+
get each() {
|
|
1085
|
+
return selectedMatch()?.matches ?? [];
|
|
1086
|
+
},
|
|
1087
|
+
children: (hit: SearchSessionMatch["matches"][number], idx: () => number) => {
|
|
1088
|
+
const isActiveSnippet = () => idx() === selectedSnippetIndex();
|
|
1089
|
+
return el(
|
|
1090
|
+
"box",
|
|
978
1091
|
{
|
|
979
|
-
|
|
1092
|
+
id: () => `snippet-row-${idx()}`,
|
|
1093
|
+
flexDirection: "column",
|
|
1094
|
+
paddingLeft: 1,
|
|
1095
|
+
marginBottom: 1,
|
|
1096
|
+
border: ["left"],
|
|
1097
|
+
borderColor: () =>
|
|
980
1098
|
isActiveSnippet()
|
|
981
1099
|
? theme().text.action.primary.base
|
|
982
|
-
: theme().
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
hit.kind === "title"
|
|
988
|
-
? "[TITLE]"
|
|
989
|
-
: hit.kind === "fuzzy"
|
|
990
|
-
? `[FUZZY · ${hit.role.toUpperCase()}]`
|
|
991
|
-
: hit.kind === "filepath"
|
|
992
|
-
? "[FILE]"
|
|
993
|
-
: hit.kind === "tool"
|
|
994
|
-
? `[TOOL:${hit.toolName || "call"}]`
|
|
995
|
-
: hit.role === "user"
|
|
996
|
-
? "[USER]"
|
|
997
|
-
: "[ASSISTANT]";
|
|
998
|
-
const prefix = isActiveSnippet() ? "› " : "";
|
|
999
|
-
return `${prefix}${roleTag} · ${formatRelativeTime(hit.timeCreated)}`;
|
|
1000
|
-
}
|
|
1001
|
-
),
|
|
1002
|
-
el(
|
|
1003
|
-
"text",
|
|
1004
|
-
{
|
|
1005
|
-
wrapMode: "word",
|
|
1006
|
-
fg: () => theme().text.base,
|
|
1100
|
+
: theme().border.base,
|
|
1101
|
+
onMouseUp: () => {
|
|
1102
|
+
setSelectedSnippetIndex(idx());
|
|
1103
|
+
openSelected(hit);
|
|
1104
|
+
},
|
|
1007
1105
|
},
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1106
|
+
el(
|
|
1107
|
+
"text",
|
|
1108
|
+
{
|
|
1109
|
+
fg: () =>
|
|
1110
|
+
isActiveSnippet()
|
|
1111
|
+
? theme().text.action.primary.base
|
|
1112
|
+
: theme().text.muted,
|
|
1113
|
+
attributes: TextAttributes.BOLD,
|
|
1011
1114
|
},
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
"
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
"text",
|
|
1062
|
-
{ fg: () => theme().text.muted, flexShrink: 0, wrapMode: "none" },
|
|
1063
|
-
"0 tokens"
|
|
1115
|
+
() => {
|
|
1116
|
+
const roleTag =
|
|
1117
|
+
hit.kind === "title"
|
|
1118
|
+
? "[TITLE]"
|
|
1119
|
+
: hit.kind === "fuzzy"
|
|
1120
|
+
? `[FUZZY · ${hit.role.toUpperCase()}]`
|
|
1121
|
+
: hit.kind === "filepath"
|
|
1122
|
+
? "[FILE]"
|
|
1123
|
+
: hit.kind === "tool"
|
|
1124
|
+
? `[TOOL:${hit.toolName || "call"}]`
|
|
1125
|
+
: hit.role === "user"
|
|
1126
|
+
? "[USER]"
|
|
1127
|
+
: "[ASSISTANT]";
|
|
1128
|
+
const prefix = isActiveSnippet() ? "▸ " : "";
|
|
1129
|
+
return `${prefix}${roleTag} · ${formatRelativeTime(hit.timeCreated)}`;
|
|
1130
|
+
}
|
|
1131
|
+
),
|
|
1132
|
+
el(
|
|
1133
|
+
"text",
|
|
1134
|
+
{
|
|
1135
|
+
wrapMode: "word",
|
|
1136
|
+
fg: () => theme().text.base,
|
|
1137
|
+
},
|
|
1138
|
+
createComponent(For, {
|
|
1139
|
+
get each() {
|
|
1140
|
+
return splitHighlightedText(hit.snippet, hit.matchedTerm);
|
|
1141
|
+
},
|
|
1142
|
+
children: (seg: { text: string; match: boolean }) =>
|
|
1143
|
+
el(
|
|
1144
|
+
"span",
|
|
1145
|
+
{
|
|
1146
|
+
fg: () =>
|
|
1147
|
+
seg.match
|
|
1148
|
+
? theme().text.action.primary.base
|
|
1149
|
+
: theme().text.base,
|
|
1150
|
+
attributes: () =>
|
|
1151
|
+
seg.match ? TextAttributes.BOLD : undefined,
|
|
1152
|
+
},
|
|
1153
|
+
seg.text
|
|
1154
|
+
),
|
|
1155
|
+
})
|
|
1156
|
+
)
|
|
1157
|
+
);
|
|
1158
|
+
},
|
|
1159
|
+
})
|
|
1160
|
+
);
|
|
1161
|
+
},
|
|
1162
|
+
})
|
|
1163
|
+
)
|
|
1064
1164
|
)
|
|
1065
1165
|
)
|
|
1066
1166
|
);
|