@nandoblanco/opencode-local-search 1.0.1 → 1.1.0

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/src/tui.ts CHANGED
@@ -364,7 +364,7 @@ function createTuiRenderer() {
364
364
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
365
365
  const handleKeyPress = (event: any) => {
366
366
  const name = String(event.name || "").toLowerCase();
367
- const enter = ["return", "enter", "linefeed"].includes(name);
367
+ const enter = ["return", "enter", "kpenter", "linefeed"].includes(name);
368
368
 
369
369
  if (name === "escape") {
370
370
  event.preventDefault();
@@ -542,117 +542,149 @@ function createTuiRenderer() {
542
542
  queueMicrotask(applyDialogWidth);
543
543
  },
544
544
  width: "100%",
545
- height: 28,
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
- paddingX: 2,
557
- paddingTop: 1,
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
- fg: () => theme().text.base,
573
+ wrapMode: "none",
574
+ flexShrink: 0,
575
+ fg: () => theme().text.action.primary.base,
567
576
  attributes: TextAttributes.BOLD,
568
577
  },
569
- "Session Search"
578
+ "opencode / search"
570
579
  ),
571
580
  el(
572
581
  "text",
573
- { fg: () => theme().text.muted },
574
- () =>
575
- loading()
576
- ? "indexing SQLite..."
577
- : `${results().length} of ${indexData().sessions.length} sessions`
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
- "box",
591
+ "text",
582
592
  {
583
- flexDirection: "row",
584
- gap: 2,
585
- alignItems: "center",
593
+ wrapMode: "none",
594
+ flexShrink: 0,
595
+ fg: () => theme().text.muted,
586
596
  },
587
- el(
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. Search Input + Filter Pills Row
601
+ // 2. Boxed Filter + Pills Card
604
602
  el(
605
603
  "box",
606
604
  {
607
605
  flexDirection: "column",
608
- paddingX: 2,
609
- paddingY: 1,
610
- gap: 1,
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
- border: ["bottom"],
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
- fg: () =>
626
- focusPane() === "search"
627
- ? theme().text.action.primary.base
628
- : theme().text.muted,
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("input", {
634
- id: "session-search-input",
635
- ref: (r: unknown) => {
636
- inputRef = r;
637
- if (props.initialQuery && r && (r as { value?: string }).value !== props.initialQuery) {
638
- (r as { value: string }).value = props.initialQuery;
639
- }
641
+ el(
642
+ "box",
643
+ {
644
+ flexGrow: 1,
645
+ flexShrink: 1,
646
+ minWidth: 0,
640
647
  },
641
- flexGrow: 1,
642
- value: () => query(),
643
- focused: () => focusPane() === "search",
644
- maxLength: 2000,
645
- placeholder:
646
- "Search keywords, \"exact phrase\", /regex/i, ~fuzzy, role:user, date:7d, file:path, tool:name...",
647
- placeholderColor: () => theme().text.muted,
648
- textColor: () => theme().text.base,
649
- focusedTextColor: () => theme().text.formfield.focused,
650
- cursorColor: () => theme().text.formfield.focused,
651
- backgroundColor: () => theme().background.base,
652
- focusedBackgroundColor: () => theme().background.formfield.focused,
653
- onMouseDown: () => setFocusPane("search"),
654
- onInput: (val: string) => setQuery(val),
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 (Left: Session List, Right: Match Preview)
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 Pane: Results List (44% width)
773
+ // Left Card: Results List (44% width)
740
774
  el(
741
- "scrollbox",
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
- border: ["right"],
781
+ backgroundColor: () =>
782
+ theme().background.raised?.base ?? theme().background.base,
783
+ border: true,
751
784
  borderColor: () =>
752
- focusPane() === "list" ? theme().text.base : theme().border.base,
753
- scrollbarOptions: { visible: false },
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
- createComponent(Show, {
757
- get when() {
758
- return !loading() && results().length > 0;
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
- get fallback() {
761
- return el(
762
- "box",
763
- { paddingX: 2, paddingY: 1 },
764
- el(
765
- "text",
766
- { fg: () => theme().text.muted },
767
- () =>
768
- loading()
769
- ? "Loading sessions..."
770
- : errorMsg()
771
- ? `Error: ${errorMsg()}`
772
- : "No matching sessions found. Try ~fuzzy, scope:all, or fewer terms."
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
- get children() {
777
- return createComponent(For, {
778
- get each() {
779
- return results();
780
- },
781
- children: (item: SearchSessionMatch, idx: () => number) => {
782
- const isSelected = () => selectedIndex() === idx();
783
- return el(
784
- "box",
785
- {
786
- id: () => `session-row-${idx()}`,
787
- flexDirection: "column",
788
- paddingX: 1,
789
- paddingY: 0,
790
- marginBottom: 1,
791
- flexShrink: 0,
792
- backgroundColor: () =>
793
- isSelected()
794
- ? theme().background.action.primary.focused
795
- : undefined,
796
- onMouseUp: () => {
797
- setSelectedIndex(idx());
798
- openSelected();
799
- },
800
- onMouseOver: () => {
801
- setSelectedIndex(idx());
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
- flexDirection: "row",
808
- justifyContent: "space-between",
809
- width: "100%",
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
- "text",
880
+ "box",
813
881
  {
814
- wrapMode: "none",
815
- truncate: true,
816
- flexShrink: 1,
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
- `${isSelected() ? "› " : " "}${item.session.title}`
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
- flexShrink: 0,
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
- el(
843
- "text",
844
- {
845
- wrapMode: "none",
846
- truncate: true,
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 Pane: Rich Match & Session Context Preview (56% width)
937
+ // Right Card: Rich Match & Session Context Preview (56% width)
862
938
  el(
863
- "scrollbox",
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
- paddingX: 2,
873
- paddingY: 1,
874
- focused: () => focusPane() === "preview",
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
- createComponent(Show, {
878
- get when() {
879
- return selectedMatch();
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
- get fallback() {
882
- return el(
883
- "text",
884
- { fg: () => theme().text.muted },
885
- "Select a session on the left to inspect matching messages, tools, and files."
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
- get children() {
889
- return el(
890
- "box",
891
- { flexDirection: "column", gap: 1 },
892
- el(
893
- "text",
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, wrapMode: "word" },
903
- () => {
904
- const m = selectedMatch();
905
- if (!m) return "";
906
- const dir = m.session.directory
907
- ? props.context.ui.format.path(m.session.directory)
908
- : "(no directory)";
909
- return `${dir} · updated ${formatRelativeTime(m.session.timeUpdated)} · ${m.totalMatches} match${m.totalMatches === 1 ? "" : "es"}`;
910
- }
911
- ),
912
- createComponent(Show, {
913
- get when() {
914
- return (selectedMatch()?.session.tools.length ?? 0) > 0;
915
- },
916
- get children() {
917
- return el(
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
- { fg: () => theme().text.muted, wrapMode: "word" },
920
- () =>
921
- `Tools: ${selectedMatch()?.session.tools.slice(0, 8).join(", ")}`
922
- );
923
- },
924
- }),
925
- createComponent(Show, {
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
- `Files: ${selectedMatch()
935
- ?.session.files.slice(0, 4)
936
- .map((f: string) => props.context.ui.format.path(f))
937
- .join(", ")}${(selectedMatch()?.session.files.length ?? 0) > 4 ? ` (+${(selectedMatch()?.session.files.length ?? 0) - 4} more)` : ""}`
938
- );
939
- },
940
- }),
941
- el(
942
- "text",
943
- {
944
- fg: () => theme().text.base,
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
- el(
977
- "text",
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
- fg: () =>
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().text.muted,
983
- attributes: TextAttributes.BOLD,
984
- },
985
- () => {
986
- const roleTag =
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
- createComponent(For, {
1009
- get each() {
1010
- return splitHighlightedText(hit.snippet, hit.matchedTerm);
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
- children: (seg: { text: string; match: boolean }) =>
1013
- el(
1014
- "span",
1015
- {
1016
- fg: () =>
1017
- seg.match
1018
- ? theme().text.action.primary.base
1019
- : theme().text.base,
1020
- attributes: () =>
1021
- seg.match ? TextAttributes.BOLD : undefined,
1022
- },
1023
- seg.text
1024
- ),
1025
- })
1026
- )
1027
- );
1028
- },
1029
- })
1030
- );
1031
- },
1032
- })
1033
- )
1034
- ),
1035
-
1036
- // 4. Footer Shortcut Bar
1037
- el(
1038
- "box",
1039
- {
1040
- flexDirection: "row",
1041
- justifyContent: "space-between",
1042
- gap: 2,
1043
- paddingX: 2,
1044
- paddingY: 1,
1045
- flexShrink: 0,
1046
- border: ["top"],
1047
- borderColor: () => theme().border.base,
1048
- },
1049
- el(
1050
- "text",
1051
- {
1052
- fg: () => theme().text.muted,
1053
- flexShrink: 1,
1054
- minWidth: 0,
1055
- wrapMode: "none",
1056
- truncate: true,
1057
- },
1058
- "enter open · ↑/↓ or ^n/^k select · ^p scope · ^g role · ^t date · ^r mode · tab pane"
1059
- ),
1060
- el(
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
  );
@@ -1190,9 +1290,13 @@ function scrollToMatchedMessage(
1190
1290
  (a.viewport?.width ?? 0) * (a.viewport?.height ?? 0)
1191
1291
  );
1192
1292
  const scrollBox = scrollBoxes[0];
1193
- const topChildren =
1293
+ const contentRoot =
1194
1294
  typeof scrollBox.content?.getChildren === "function"
1195
- ? scrollBox.content.getChildren()
1295
+ ? scrollBox.content
1296
+ : scrollBox;
1297
+ const topChildren =
1298
+ typeof contentRoot?.getChildren === "function"
1299
+ ? contentRoot.getChildren()
1196
1300
  : [];
1197
1301
  if (!topChildren.length || (scrollBox.scrollHeight ?? 0) <= 0) {
1198
1302
  return false;
@@ -1255,7 +1359,7 @@ function scrollToMatchedMessage(
1255
1359
  walkContent(child);
1256
1360
  }
1257
1361
  };
1258
- walkContent(scrollBox.content);
1362
+ walkContent(contentRoot);
1259
1363
 
1260
1364
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1261
1365
  let targetNode: any = idMatchNode;