@luxass/pi-session-search 0.0.0-stage → 0.0.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/LICENSE +21 -0
- package/README.md +85 -2
- package/package.json +49 -3
- package/src/current-session-search.ts +233 -0
- package/src/display-text.ts +391 -0
- package/src/finder-overlay.ts +1075 -0
- package/src/hits.ts +77 -0
- package/src/index-client.ts +404 -0
- package/src/index-search.ts +578 -0
- package/src/index-worker.ts +102 -0
- package/src/index.ts +196 -0
- package/src/jsonl-reader.ts +100 -0
- package/src/match-text.ts +65 -0
- package/src/open-match.ts +544 -0
- package/src/query.ts +490 -0
- package/src/searchable-text.ts +176 -0
- package/src/session-index.ts +577 -0
- package/src/transcript-scroll.ts +456 -0
- package/src/worker-protocol.ts +66 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026-PRESENT Lucas Nørgård
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,86 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @luxass/pi-session-search
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Find any message in your [Pi](https://pi.dev) sessions and jump straight to it: user prompts, assistant answers, tool calls, tool output, and `!` shell commands, on every branch.
|
|
4
|
+
|
|
5
|
+
```text
|
|
6
|
+
/find retry search this session
|
|
7
|
+
/find-all t:bash deploy search every session for bash calls and output about deploys
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
pi install npm:@luxass/pi-session-search
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
To try it from this repository, run `pi -e ./packages/pi-session-search`. It needs Node.js 24 or later for `node:sqlite`, and Pi's interactive terminal UI.
|
|
17
|
+
|
|
18
|
+
## Use
|
|
19
|
+
|
|
20
|
+
`/find` searches the session you are in, in memory. `/find-all` searches every session on this machine through a local index. Anything after the command becomes the starting query, and results update as you type.
|
|
21
|
+
|
|
22
|
+
Each row shows what kind of message matched, a snippet with the match highlighted, and how old it is. Rows from other sessions also show the session name or folder, and `branch` marks a match that is not on the branch Pi would open. The preview below the list shows the selected match in context.
|
|
23
|
+
|
|
24
|
+
In `/find-all`, results are grouped by session. Each group starts with the session name or folder, its match count, and the age of its newest match, and your open session is marked `this session`. One session shows at most 20 matches, and `20+` means it has more: narrow the query or run `/find` in that session to see them.
|
|
25
|
+
|
|
26
|
+
`/find-all` searches your open session in memory, not through the index, so its newest messages show at once, even before Pi has saved the session to a file.
|
|
27
|
+
|
|
28
|
+
| Key | Action |
|
|
29
|
+
| ------------------------------------------- | --------------------------------------------------- |
|
|
30
|
+
| Up / Down, Ctrl-P / Ctrl-N, Ctrl-K / Ctrl-J | Select a result |
|
|
31
|
+
| PageUp / PageDown | Select a page further |
|
|
32
|
+
| Ctrl-U / Ctrl-D | Scroll the preview |
|
|
33
|
+
| Tab / Shift-Tab | Show all messages, or only user, assistant, or tool |
|
|
34
|
+
| Ctrl-S | Switch between this session and all sessions |
|
|
35
|
+
| Enter | Open the selected match |
|
|
36
|
+
| Alt-Enter | Close and insert the match into the prompt |
|
|
37
|
+
| Ctrl-X | Copy the match and keep the picker open |
|
|
38
|
+
| Esc / Ctrl-C | Close |
|
|
39
|
+
|
|
40
|
+
Copy and insert use the whole message, not only the part in the preview. Terminal escape codes and control characters are removed first, but newlines and tabs are kept. Insert adds the text at the cursor, so your draft stays. Ctrl-X is Pi's copy key, the same one `/tree` uses. If you change `app.message.copy`, your key works here too. If the session file has changed since the search, copy and insert fail. Search again to fix this.
|
|
41
|
+
|
|
42
|
+
### Writing a query
|
|
43
|
+
|
|
44
|
+
Every word must appear somewhere in the message, in any order. Words match inside other words, so `quest` finds `request`. Case is ignored unless the query has an uppercase letter.
|
|
45
|
+
|
|
46
|
+
| Write | To find |
|
|
47
|
+
| -------------------- | --------------------------------------------------------- |
|
|
48
|
+
| `"exit code 1"` | That exact phrase |
|
|
49
|
+
| `u:` or `user:` | Your messages and `!` shell commands |
|
|
50
|
+
| `a:` or `assistant:` | Assistant answers (thinking is never searched) |
|
|
51
|
+
| `t:` or `tool:` | Tool calls and their output; `t:bash` for one tool |
|
|
52
|
+
| `tc:` or `call:` | Tool calls only, such as `tc:edit` |
|
|
53
|
+
| `tr:` or `result:` | Tool output only, such as `tr:bash` |
|
|
54
|
+
| `cwd:dots` | Sessions whose folder contains `dots` (all sessions only) |
|
|
55
|
+
| `name:auth` | Sessions whose name contains `auth`; `title:` also works |
|
|
56
|
+
| `since:2d` | Messages from the last 2 days; also `3h`, `1w`, a date |
|
|
57
|
+
| `until:2026-11-01` | Messages before Nov 1, 2026; also `2d`, `3h`, `1w` |
|
|
58
|
+
|
|
59
|
+
A date means the start of that day in your time zone. A query with only filters, such as `since:1d`, lists every matching message, newest first.
|
|
60
|
+
|
|
61
|
+
A filter can carry a word, so `u:deploy` finds your messages about deploys. Tool names also match without their namespace: `t:bash` finds `mcp__server__bash`. In `/find`, if no message matches exactly, the picker shows fuzzy matches and says `fuzzy`.
|
|
62
|
+
|
|
63
|
+
### What Enter does
|
|
64
|
+
|
|
65
|
+
| The match is… | Pi… |
|
|
66
|
+
| --------------------------------- | ------------------------------------------------------------------- |
|
|
67
|
+
| On your current branch | Closes the picker and scrolls to the message |
|
|
68
|
+
| On another branch of this session | Asks, moves to the newest point of that branch, then scrolls |
|
|
69
|
+
| In another session | Asks, opens that session, asks again if the branch differs, scrolls |
|
|
70
|
+
|
|
71
|
+
Enter never opens a result from an older query. If `/find-all` is still updating the list, the status line asks you to press Enter again. Moving to another branch or session waits until Pi is idle.
|
|
72
|
+
|
|
73
|
+
Scrolling needs Pi's fullscreen mode, which is the default. Pi has no public API to scroll the transcript, so the extension looks up the rendered message by its id, or by its text when there is no id. If the match is inside collapsed tool output, Pi expands that output and scrolls to the matched line. Ctrl-O, Pi's default key for expanding tool output, toggles it again. If the line still can't be shown, the transcript stops at the top of that tool call and Pi tells you. If the message is not shown at all, for example after a compaction, Pi tells you instead.
|
|
74
|
+
|
|
75
|
+
## The index
|
|
76
|
+
|
|
77
|
+
`/find-all` keeps its index in `~/.pi/agent/cache/session-search/index.sqlite`. It covers `~/.pi/agent/sessions/`, and the current session's folder if you use a custom session directory. You can delete it at any time; it rebuilds on the next `/find-all`.
|
|
78
|
+
|
|
79
|
+
- **No copies of your messages.** The index holds trigrams of each message and where the message sits in its session file. Every result is read back from the file and checked with the same rules as `/find`.
|
|
80
|
+
- **Kept up to date in the background.** A worker updates the index shortly after Pi starts and whenever you open `/find-all`. It reads only what was added since the last update, and indexes a file again if it was replaced or rewritten. A search never shows text that is no longer in the file.
|
|
81
|
+
- **Short words are limited.** Words under three characters can't use the index, so they are checked against recent messages only. A count such as `200+ matches` means the search stopped early.
|
|
82
|
+
- **Safe with several Pi windows.** They share one index without indexing anything twice.
|
|
83
|
+
|
|
84
|
+
## Credits
|
|
85
|
+
|
|
86
|
+
Inspired by Dillon Mulroy's [session-finder](https://github.com/dmmulroy/.dotfiles/tree/main/home/.pi/agent/extensions/session-finder) extension for Pi.
|
package/package.json
CHANGED
|
@@ -1,6 +1,52 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luxass/pi-session-search",
|
|
3
|
-
"version": "0.0.0
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Search the current Pi session or every past session, then jump to a match.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"pi",
|
|
7
|
+
"pi-extension",
|
|
8
|
+
"pi-package",
|
|
9
|
+
"search",
|
|
10
|
+
"sessions"
|
|
11
|
+
],
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "https://github.com/luxass/agent-extensions",
|
|
16
|
+
"directory": "packages/pi-session-search"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"src",
|
|
20
|
+
"README.md",
|
|
21
|
+
"LICENSE"
|
|
22
|
+
],
|
|
23
|
+
"type": "module",
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@earendil-works/pi-coding-agent": "1.6.0",
|
|
29
|
+
"@earendil-works/pi-tui": "1.6.0"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"@earendil-works/pi-coding-agent": "*",
|
|
33
|
+
"@earendil-works/pi-tui": "*"
|
|
34
|
+
},
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": ">=24"
|
|
37
|
+
},
|
|
38
|
+
"pi": {
|
|
39
|
+
"image": "https://raw.githubusercontent.com/luxass/agent-extensions/main/packages/pi-session-search/docs/cover.png",
|
|
40
|
+
"extensions": [
|
|
41
|
+
"./src/index.ts"
|
|
42
|
+
]
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"lint": "oxlint .",
|
|
46
|
+
"lint:fix": "oxlint --fix .",
|
|
47
|
+
"fmt": "oxfmt .",
|
|
48
|
+
"fmt:check": "oxfmt --check .",
|
|
49
|
+
"typecheck": "tsc -p tsconfig.json",
|
|
50
|
+
"test": "node --test \"test/**/*.test.ts\""
|
|
51
|
+
}
|
|
6
52
|
}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* /find: searches the current session in memory, across every branch.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { fuzzyMatch } from "@earendil-works/pi-tui";
|
|
6
|
+
|
|
7
|
+
import { type SearchHit, windowAroundMatch } from "./hits.ts";
|
|
8
|
+
import {
|
|
9
|
+
cwdMatches,
|
|
10
|
+
inTimeRange,
|
|
11
|
+
kindAllowed,
|
|
12
|
+
matchesItem,
|
|
13
|
+
parseQuery,
|
|
14
|
+
type ParsedQuery,
|
|
15
|
+
resolveTimeRange,
|
|
16
|
+
type RoleFilter,
|
|
17
|
+
sessionNameMatches,
|
|
18
|
+
termPatterns,
|
|
19
|
+
type TimeRange,
|
|
20
|
+
toolNameMatches,
|
|
21
|
+
} from "./query.ts";
|
|
22
|
+
import { extractSearchableItems, type SearchableItem } from "./searchable-text.ts";
|
|
23
|
+
|
|
24
|
+
/** What the searcher needs to know about the open session. Plain data, so tests can build it. */
|
|
25
|
+
export interface CurrentSessionSnapshot {
|
|
26
|
+
sessionFile: string | undefined;
|
|
27
|
+
sessionId: string;
|
|
28
|
+
sessionName?: string;
|
|
29
|
+
cwd: string;
|
|
30
|
+
/** Every entry of the session file, in file order. */
|
|
31
|
+
entries: readonly unknown[];
|
|
32
|
+
/** Entry ids on the branch that is open now. */
|
|
33
|
+
activeEntryIds: ReadonlySet<string>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface SearchOutcome {
|
|
37
|
+
hits: SearchHit[];
|
|
38
|
+
/** Number of matches, which can exceed hits.length. */
|
|
39
|
+
total: number;
|
|
40
|
+
/** True when no literal match existed and the hits come from the fuzzy fallback. */
|
|
41
|
+
fuzzy: boolean;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Current-session matches for merging into the all-sessions results. */
|
|
45
|
+
export interface AllSessionsOutcome {
|
|
46
|
+
/** Newest first, at most the per-session limit. */
|
|
47
|
+
hits: SearchHit[];
|
|
48
|
+
/** True when more matches existed than the per-session limit allowed. */
|
|
49
|
+
hasMore: boolean;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** How much of each message the fuzzy fallback looks at. */
|
|
53
|
+
const FUZZY_PREFIX_CHARS = 160;
|
|
54
|
+
|
|
55
|
+
export class CurrentSessionSearcher {
|
|
56
|
+
private readonly snapshot: CurrentSessionSnapshot;
|
|
57
|
+
/** Newest first, which is the result order. */
|
|
58
|
+
private readonly items: SearchableItem[];
|
|
59
|
+
|
|
60
|
+
constructor(snapshot: CurrentSessionSnapshot) {
|
|
61
|
+
this.snapshot = snapshot;
|
|
62
|
+
const items: SearchableItem[] = [];
|
|
63
|
+
for (const entry of snapshot.entries) {
|
|
64
|
+
items.push(...extractSearchableItems(entry));
|
|
65
|
+
}
|
|
66
|
+
items.reverse();
|
|
67
|
+
// Entries are in append order; a stable sort keeps that order for equal timestamps.
|
|
68
|
+
items.sort((left, right) => right.timestamp - left.timestamp);
|
|
69
|
+
this.items = items;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Key of this session in grouped results, the same as the picker's group
|
|
74
|
+
* key: the session file, or the session id when there is no file.
|
|
75
|
+
*/
|
|
76
|
+
get sessionKey(): string {
|
|
77
|
+
return this.snapshot.sessionFile ?? this.snapshot.sessionId;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* True when `hit` belongs to this session: the same session file, or the
|
|
82
|
+
* same session id when this session has no file.
|
|
83
|
+
*/
|
|
84
|
+
isSameSession(hit: Pick<SearchHit, "sessionFile" | "sessionId">): boolean {
|
|
85
|
+
const file = this.snapshot.sessionFile;
|
|
86
|
+
return file === undefined
|
|
87
|
+
? hit.sessionId === this.snapshot.sessionId
|
|
88
|
+
: hit.sessionFile === file;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** True when `hit` belongs to this session, so fullText() can answer for it. */
|
|
92
|
+
owns(hit: Pick<SearchHit, "sessionFile" | "sessionId">): boolean {
|
|
93
|
+
return this.snapshot.sessionFile === undefined
|
|
94
|
+
? hit.sessionFile === undefined && hit.sessionId === this.snapshot.sessionId
|
|
95
|
+
: hit.sessionFile === this.snapshot.sessionFile;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** The whole text of an item, which a hit may only show part of. Undefined if unknown. */
|
|
99
|
+
fullText(entryId: string, part: number): string | undefined {
|
|
100
|
+
return this.items.find((item) => item.entryId === entryId && item.part === part)?.text;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** Number of searchable items, for the picker's status line. */
|
|
104
|
+
get size(): number {
|
|
105
|
+
return this.items.length;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Finds matches newest first. `now` is the time relative since: and until:
|
|
110
|
+
* values count back from; the picker passes the time of the keystroke.
|
|
111
|
+
*/
|
|
112
|
+
search(
|
|
113
|
+
queryText: string,
|
|
114
|
+
roleFilter: RoleFilter,
|
|
115
|
+
limit = 500,
|
|
116
|
+
now: number = Date.now(),
|
|
117
|
+
): SearchOutcome {
|
|
118
|
+
const query = parseQuery(queryText);
|
|
119
|
+
// name: applies to the whole session, so it keeps every message or none.
|
|
120
|
+
if (query.name !== undefined && !sessionNameMatches(this.snapshot.sessionName, query.name)) {
|
|
121
|
+
return { hits: [], total: 0, fuzzy: false };
|
|
122
|
+
}
|
|
123
|
+
const timeRange = resolveTimeRange(query, now);
|
|
124
|
+
const patterns = termPatterns(query);
|
|
125
|
+
const hits: SearchHit[] = [];
|
|
126
|
+
let total = 0;
|
|
127
|
+
|
|
128
|
+
for (const item of this.items) {
|
|
129
|
+
if (
|
|
130
|
+
!inTimeRange(item.timestamp, timeRange) ||
|
|
131
|
+
!matchesItem(item, query, roleFilter, patterns)
|
|
132
|
+
) {
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
total += 1;
|
|
136
|
+
if (hits.length < limit) {
|
|
137
|
+
hits.push(this.toHit(item, patterns, false));
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (total === 0 && query.terms.length > 0) {
|
|
142
|
+
return this.fuzzySearch(query, timeRange, roleFilter, limit);
|
|
143
|
+
}
|
|
144
|
+
return { hits, total, fuzzy: false };
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Matches of this session for /find-all, which uses them instead of the
|
|
149
|
+
* index's possibly outdated copy. Follows the index search: literal matches
|
|
150
|
+
* only, no fuzzy fallback, cwd: and name: checked against this session,
|
|
151
|
+
* since: and until: counted back from `now`, and at most `perSessionLimit` hits.
|
|
152
|
+
*/
|
|
153
|
+
searchForAllSessions(
|
|
154
|
+
queryText: string,
|
|
155
|
+
roleFilter: RoleFilter,
|
|
156
|
+
perSessionLimit: number,
|
|
157
|
+
now: number = Date.now(),
|
|
158
|
+
): AllSessionsOutcome {
|
|
159
|
+
const query = parseQuery(queryText);
|
|
160
|
+
if (query.cwd !== undefined && !cwdMatches(this.snapshot.cwd, query.cwd)) {
|
|
161
|
+
return { hits: [], hasMore: false };
|
|
162
|
+
}
|
|
163
|
+
if (query.name !== undefined && !sessionNameMatches(this.snapshot.sessionName, query.name)) {
|
|
164
|
+
return { hits: [], hasMore: false };
|
|
165
|
+
}
|
|
166
|
+
const timeRange = resolveTimeRange(query, now);
|
|
167
|
+
const patterns = termPatterns(query);
|
|
168
|
+
const hits: SearchHit[] = [];
|
|
169
|
+
for (const item of this.items) {
|
|
170
|
+
if (
|
|
171
|
+
!inTimeRange(item.timestamp, timeRange) ||
|
|
172
|
+
!matchesItem(item, query, roleFilter, patterns)
|
|
173
|
+
) {
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
if (hits.length >= perSessionLimit) {
|
|
177
|
+
return { hits, hasMore: true };
|
|
178
|
+
}
|
|
179
|
+
hits.push(this.toHit(item, patterns, false));
|
|
180
|
+
}
|
|
181
|
+
return { hits, hasMore: false };
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/** Fallback when nothing matches literally: fuzzy-match the start of each message. */
|
|
185
|
+
private fuzzySearch(
|
|
186
|
+
query: ParsedQuery,
|
|
187
|
+
timeRange: TimeRange,
|
|
188
|
+
roleFilter: RoleFilter,
|
|
189
|
+
limit: number,
|
|
190
|
+
): SearchOutcome {
|
|
191
|
+
const scored: Array<{ item: SearchableItem; score: number; order: number }> = [];
|
|
192
|
+
this.items.forEach((item, order) => {
|
|
193
|
+
if (!inTimeRange(item.timestamp, timeRange) || !kindAllowed(item.kind, query, roleFilter)) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
if (query.toolName !== undefined && !toolNameMatches(item.toolName, query.toolName)) {
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
const result = fuzzyMatch(query.fuzzyText, item.text.slice(0, FUZZY_PREFIX_CHARS));
|
|
200
|
+
if (result.matches) {
|
|
201
|
+
scored.push({ item, score: result.score, order });
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
scored.sort((left, right) => left.score - right.score || left.order - right.order);
|
|
205
|
+
const hits = scored.slice(0, limit).map(({ item }) => this.toHit(item, [], true));
|
|
206
|
+
return { hits, total: scored.length, fuzzy: true };
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
private toHit(item: SearchableItem, patterns: RegExp[], fuzzy: boolean): SearchHit {
|
|
210
|
+
const window = windowAroundMatch(item.text, patterns);
|
|
211
|
+
const hit: SearchHit = {
|
|
212
|
+
sessionFile: this.snapshot.sessionFile,
|
|
213
|
+
sessionId: this.snapshot.sessionId,
|
|
214
|
+
cwd: this.snapshot.cwd,
|
|
215
|
+
entryId: item.entryId,
|
|
216
|
+
part: item.part,
|
|
217
|
+
kind: item.kind,
|
|
218
|
+
timestamp: item.timestamp,
|
|
219
|
+
onActiveBranch: this.snapshot.activeEntryIds.has(item.entryId),
|
|
220
|
+
text: window.text,
|
|
221
|
+
clippedStart: window.clippedStart,
|
|
222
|
+
clippedEnd: window.clippedEnd,
|
|
223
|
+
fuzzy,
|
|
224
|
+
};
|
|
225
|
+
if (this.snapshot.sessionName !== undefined) {
|
|
226
|
+
hit.sessionName = this.snapshot.sessionName;
|
|
227
|
+
}
|
|
228
|
+
if (item.toolName !== undefined) {
|
|
229
|
+
hit.toolName = item.toolName;
|
|
230
|
+
}
|
|
231
|
+
return hit;
|
|
232
|
+
}
|
|
233
|
+
}
|