@nandoblanco/opencode-local-search 1.0.2 → 1.2.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/CHANGELOG.md ADDED
@@ -0,0 +1,29 @@
1
+ # Changelog
2
+
3
+ ## 1.2.0 (2026-11-17)
4
+
5
+ - Renamed OpenCode Desktop sidebar label (`vertical-tabs-search`), panel tab title, and dialog title from `Search sessions` to `Search` and stripped any trailing shortcut badge from the left sidebar button (`src/gui.tsx`).
6
+ - Added a centered loading spinner overlay (`.ols-loading-center` / `.ols-loading-pill`) inside the search results split view (`src/gui.tsx`, `src/gui.css`) and reduced search input debounce to 16ms.
7
+ - Accelerated session search (`src/search.ts`, `src/server.ts`) with incremental SQLite `session_v2` delta indexing (`time_updated > cachedMaxUpdated`), skipping redundant V1 fallback table scans when V2 sessions exist, and prewarming the index on server plugin startup.
8
+ - Added session sort modes (`updated`, `relevance`, `newest`, `oldest`, `title`, `context`, `tokens`) via `src/sort.ts` with interactive sort controls in `/search` TUI (`src/tui.ts`) and OpenCode Desktop (`src/gui.tsx`).
9
+ - Included `archived`, `contextTokens`, and `totalTokens` session metadata in RPC and server search responses (`src/rpc.ts`, `src/server.ts`).
10
+
11
+ ## 1.1.0 (2026-11-12)
12
+
13
+ - Added OpenCode Desktop Session Search (`src/gui.tsx`, `src/gui.css`, `dist/gui-experimental.cjs`, and `SearchRpc` in `src/rpc.ts`) with a persistent side panel (`Ctrl+Shift+F` to open/focus, `Ctrl+Alt+F` to toggle), fallback dialog when no session is active, and routing from OpenCode Desktop's built-in titlebar, vertical-tabs, Home session search, and Search sessions dialog.
14
+ - Updated `cli.js` and `src/server.ts` to register `SearchRpc.query` for shared SQLite session search across TUI and Desktop.
15
+
16
+ ## 1.0.2 (2026-10-28)
17
+
18
+ - Refined the `/search` OpenTUI modal layout (`src/tui.ts`) with a bordered filter bar and split-pane session and message snippet cards.
19
+
20
+ ## 1.0.1 (2026-10-26)
21
+
22
+ - Scoped npm package as `@nandoblanco/opencode-local-search` with public `publishConfig` and normalized `bin` and `repository` fields.
23
+ - Hardened regex ReDoS guards in `parseQuery`, enforced inline filters during fuzzy fallback matching in `src/search.ts`, bounded the in-memory index cache, and cleaned up transcript auto-scroll timers in `src/tui.ts`.
24
+
25
+ ## 1.0.0 (2026-10-25)
26
+
27
+ - Initial release of `opencode-local-search` for OpenCode.
28
+ - Added zero-token local SQLite session indexing (`bun:sqlite` and `node:sqlite`) supporting both OpenCode V2 (`session_v2`, `session_message`) and V1 (`session`, `message`, `part`) schemas.
29
+ - Added multi-term session-level AND ranking, exact phrase matching, regex (`/pattern/i` and `re:`), bounded Levenshtein fuzzy search (`~term`), inline filter tokens (`role:`, `date:`, `file:`, `tool:`, `scope:`), one-command CLI installer (`cli.js`), and the `/search` split-pane TUI modal (`src/tui.ts`) with auto-scroll to matched messages.
package/README.md CHANGED
@@ -1,9 +1,19 @@
1
1
  # opencode-local-search
2
2
 
3
- **Local-first, zero-token interactive session search plugin for OpenCode**: indexes your local SQLite session history automatically, previews matching messages, tools, and files as you type, and jumps straight to the exact matched message in any conversation.
3
+ **Local-first, zero-token interactive session search plugin for OpenCode**: indexes local SQLite session history, previews matching messages, tools, and files as you type, and opens matching conversations from the TUI or OpenCode Desktop.
4
4
 
5
5
  ![opencode-local-search TUI preview](./assets/screenshot.png)
6
6
 
7
+ ## OpenCode Desktop Support
8
+
9
+ **Replaces OpenCode Desktop's built-in session search.** The titlebar, vertical-tabs (`Search`), Home session search, and built-in Search sessions dialog route into this plugin's `Search` interface.
10
+
11
+ **Now available in OpenCode Desktop as well as the TUI.** Search local conversation history in a persistent `Search` side panel, sort sessions by recency, relevance, creation time, title, context size, or total tokens, preview matching messages and file/tool details, and open matching sessions without a model turn. Press `Ctrl+Shift+F` to open or focus the panel, or `Ctrl+Alt+F` to toggle it. When no session is active, search opens in a fallback dialog.
12
+
13
+ **In the CLI/TUI, search is an additional tool rather than a replacement.** Open it with `/search` or the command palette. The built-in `/sessions` picker remains available.
14
+
15
+ One global OpenCode V2 plugin entry loads the server RPC bridge, TUI, and Desktop integration together. Both interfaces search the same local session history; see [Installation](#installation) for setup.
16
+
7
17
  ## Background
8
18
 
9
19
  This project started as a small local CLI script wired to a custom `/search` command. It queried OpenCode's SQLite database and printed matching session IDs into the chat, which worked as a quick prototype but had two limitations in daily use:
@@ -24,10 +34,12 @@ This project started as a small local CLI script wired to a custom `/search` com
24
34
  | Local-first, zero-token execution | Queries your local OpenCode SQLite database directly inside the TUI with zero LLM token usage, zero server tools, and zero cloud dependencies |
25
35
  | Zero external npm dependencies | Uses the SQLite driver built into OpenCode's runtime (`bun:sqlite` or `node:sqlite`) and a built-in bounded Levenshtein matcher, requiring no native C++ addons |
26
36
  | Dual-schema support (OpenCode V2 + V1) | Automatically detects and indexes both the OpenCode V2 schema (`session_v2` and `session_message`) and the V1 schema (`session`, `message`, and `part`) |
27
- | Interactive `/search` TUI modal | Wide (`80%` default, configurable via `dialogWidth`) split-pane popup with colored filter pills (`^p` scope, `^g` role, `^t` date, `^r` mode, `^l` refresh), live session list on the left, and highlighted message/tool/file snippet cards on the right |
37
+ | Interactive `/search` TUI modal | Wide (`80%` default, configurable via `dialogWidth`) split-pane popup with colored filter pills (`^p` scope, `^g` role, `^t` date, `^r` mode, `^o` sort, `^l` refresh), live session list on the left, and highlighted message/tool/file snippet cards on the right |
28
38
  | Session-level multi-term AND ranking | Searching `auth cookie` finds sessions where both terms appear anywhere across the session title, user prompts, assistant replies, tool calls, or file paths, ranking single-message co-occurrences higher |
39
+ | Multi-mode session sorting | Sort results by `Recently updated`, `Relevance`, `Newest created`, `Oldest created`, `Title A-Z`, `Latest context size`, or `Total tokens used` (`src/sort.ts`) |
29
40
  | Typo-tolerant fuzzy & regex search | Supports `"exact phrase"`, `/regex/i` (`re:`), explicit `~fuzzy` terms, and automatic bounded Levenshtein fallback when a multi-word query has a typo |
30
41
  | Auto-scroll to matched message | Pressing `Enter` (or clicking any snippet card in the preview pane) opens the session and automatically scrolls the transcript to the exact matched message |
42
+ | OpenCode Desktop search | Persistent `Search` side panel backed by `SearchRpc.query`, with a fallback dialog when no session is active, centered loading spinner, scope/query/sort controls, snippets, and session navigation |
31
43
 
32
44
  ## Installation
33
45
 
@@ -49,24 +61,24 @@ opencode plugin add github:nandoblanco/opencode-local-search
49
61
 
50
62
  ### Option 2: Manual Configuration
51
63
 
52
- Add `@nandoblanco/opencode-local-search` to `~/.config/opencode/cli.json` (or `$XDG_CONFIG_HOME/opencode/cli.json`):
64
+ Add `@nandoblanco/opencode-local-search` to the global `~/.config/opencode/opencode.jsonc` (or `$XDG_CONFIG_HOME/opencode/opencode.jsonc`) to load the server RPC bridge, TUI, and Desktop parts together:
53
65
 
54
66
  ```json
55
67
  {
56
68
  "plugins": [
57
- [
58
- "@nandoblanco/opencode-local-search",
59
- {
69
+ {
70
+ "package": "@nandoblanco/opencode-local-search",
71
+ "options": {
60
72
  "dialogWidth": "80%"
61
73
  }
62
- ]
74
+ }
63
75
  ]
64
76
  }
65
77
  ```
66
78
 
67
79
  ### From a Local Directory
68
80
 
69
- Clone or copy this folder and reference it in `~/.config/opencode/cli.json` (no `npm install` or build step required):
81
+ For development, use Node.js 26.4 or newer to meet the OpenTUI dependency's declared minimum. Clone this repository, run `npm ci` and `npm run build` to build the Desktop bundle, then reference the directory in the global `opencode.jsonc`. TUI-only use does not need the GUI build. The root `overrides` pin patched `glob` and `minimatch` versions for this repository's development dependencies; they do not alter the OpenCode host application's dependencies:
70
82
 
71
83
  ```json
72
84
  {
@@ -90,6 +102,12 @@ Clone or copy this folder and reference it in `~/.config/opencode/cli.json` (no
90
102
  }
91
103
  ```
92
104
 
105
+ ### OpenCode Desktop
106
+
107
+ Run `/search [query]` or press `Ctrl+Shift+F` (`Cmd+Shift+F` on macOS) to open and focus the persistent `Search` side panel. `Ctrl+Alt+F` (`Cmd+Option+F`) toggles it. Without an active session, these commands open a dialog. The plugin also intercepts the built-in titlebar, vertical-tab (`Search`), and home-session search entry points.
108
+
109
+ Desktop requests use a 16 ms debounce, a centered loading spinner overlay, and a sequence counter to discard stale responses. They call `SearchRpc.query` on the server, which prewarms the SQLite session index on startup and returns up to 60 session results with message snippets, token/context metadata, and file/tool details. The TUI continues to query SQLite locally. Exact-message scrolling in the TUI uses the render-tree traversal described below; Desktop uses its own session navigation path.
110
+
93
111
  ## TUI Query Syntax (`/search`)
94
112
 
95
113
  Type filters inline in the search bar or toggle them with keyboard shortcuts and clickable filter pills.
@@ -120,6 +138,7 @@ Type filters inline in the search bar or toggle them with keyboard shortcuts and
120
138
  | `Ctrl+G` | Cycle role filter pill (`all` -> `user` -> `assistant` -> `shell`) |
121
139
  | `Ctrl+T` | Cycle date filter pill (`all` -> `today` -> `yesterday` -> `7d` -> `30d`) |
122
140
  | `Ctrl+R` | Cycle search mode pill (`smart` -> `fuzzy` -> `regex`) |
141
+ | `Ctrl+O` | Cycle session sort order (`updated` -> `relevance` -> `newest` -> `oldest` -> `title` -> `context` -> `tokens`) |
123
142
  | `Ctrl+L` | Force refresh the SQLite session index |
124
143
  | `Esc` | Close popup |
125
144
 
@@ -137,7 +156,7 @@ Type filters inline in the search bar or toggle them with keyboard shortcuts and
137
156
  4. `~/.local/share/opencode/opencode.db` (macOS, Linux, Windows)
138
157
  5. `%LOCALAPPDATA%/opencode/opencode.db` (Windows fallback)
139
158
 
140
- Once loaded, `loadSessionIndex()` caches the parsed `SessionIndex` in memory for 6 seconds (`INDEX_TTL_MS = 6000`) so typing in the search bar filters in sub-millisecond time without re-querying SQLite on every keystroke (`Ctrl+L` forces an immediate re-index).
159
+ Once loaded, `loadSessionIndex()` keeps the parsed `SessionIndex` in memory (`INDEX_TTL_MS = 2000`) and performs incremental SQLite delta updates (`WHERE time_updated > cachedMaxUpdated`) so only newly modified sessions are re-read from `session_v2` and `session_message`. Typing in the search bar filters in sub-millisecond time (`Ctrl+L` or Desktop `Refresh` forces a full re-index).
141
160
 
142
161
  ### 2. Dual-Schema Indexing (OpenCode V2 + V1 Fallback)
143
162
 
@@ -204,7 +223,7 @@ When you press `Enter` on a session (or click a specific snippet card in the rig
204
223
 
205
224
  ### 7. Agent Tools Registered by the Server Plugin
206
225
 
207
- `src/server.ts` is intentionally a no-op entrypoint that registers **zero LLM agent tools**. All session indexing, filtering, and navigation happen strictly inside the TUI (`src/tui.ts`), adding **0 schema tokens** to your model context.
226
+ `src/server.ts` registers `SearchRpc.query`, implemented by `executeSearchQuery()`, for Desktop clients. It loads the read-only SQLite index and runs the same query parser and ranking functions as the TUI. The server registers **zero LLM agent tools** and adds **0 schema tokens** to model context. `src/rpc.ts` exports the shared contract; `src/gui.tsx` and `src/gui.css` build to `dist/gui-experimental.cjs` with `npm run build`.
208
227
 
209
228
  ### 8. Token Usage Breakdown
210
229
 
@@ -216,10 +235,11 @@ Every operation in `opencode-local-search` uses zero LLM tokens:
216
235
  | Live filtering, fuzzy matching & snippet preview | **0 tokens** | Runs synchronously in memory (`searchSessionIndex`) inside the TUI process on every keystroke |
217
236
  | Jumping to a matched session & message (`Enter`) | **0 tokens** | Navigates via `context.ui.router.navigate()` and scrolls the local `@opentui` transcript tree directly |
218
237
  | Server plugin entrypoint (`src/server.ts`) | **0 schema tokens** | Registers no LLM tools or system prompts |
238
+ | Desktop queries and session navigation | **0 tokens** | Uses the server RPC bridge and Desktop layout API without a model turn |
219
239
 
220
240
  ## Configuration Options
221
241
 
222
- Options can be passed in `~/.config/opencode/cli.json` (or `opencode.jsonc`) or via environment variables:
242
+ Configure the package in the global `opencode.jsonc` for all interfaces. `dialogWidth` controls the TUI popup only; Desktop uses its panel or dialog layout. TUI-specific options can also be passed in `cli.json`:
223
243
 
224
244
  ```json
225
245
  {
package/cli.js CHANGED
@@ -221,6 +221,21 @@ export async function installPlugin(options) {
221
221
  ? '["' + pkgName + '", { "dialogWidth": "' + String(opts.dialogWidth) + '" }]'
222
222
  : '"' + pkgName + '"';
223
223
 
224
+ const jsoncCandidate = path.join(configDir, cliName + ".jsonc");
225
+ const jsonCandidate = path.join(configDir, cliName + ".json");
226
+ const serverConfigFile = fs.existsSync(jsoncCandidate)
227
+ ? jsoncCandidate
228
+ : fs.existsSync(jsonCandidate)
229
+ ? jsonCandidate
230
+ : jsoncCandidate;
231
+
232
+ const serverStatus = addPluginToJsoncFile(
233
+ serverConfigFile,
234
+ "https://" + cliName + ".ai/config.json",
235
+ '"' + pkgName + '"',
236
+ matchKey
237
+ );
238
+
224
239
  const cliConfigFile = path.join(configDir, "cli.json");
225
240
  const cliStatus = addPluginToJsoncFile(
226
241
  cliConfigFile,
@@ -231,6 +246,8 @@ export async function installPlugin(options) {
231
246
 
232
247
  return {
233
248
  configDir,
249
+ serverConfigFile,
250
+ serverStatus,
234
251
  cliConfigFile,
235
252
  cliStatus,
236
253
  };
@@ -256,7 +273,8 @@ if (isDirectRun) {
256
273
  installPlugin({ configDir, dialogWidth })
257
274
  .then((res) => {
258
275
  console.log("opencode-local-search installed:");
259
- console.log(" TUI config: " + res.cliConfigFile + " (" + res.cliStatus + ")");
276
+ console.log(" Server/Desktop config: " + res.serverConfigFile + " (" + res.serverStatus + ")");
277
+ console.log(" TUI config: " + res.cliConfigFile + " (" + res.cliStatus + ")");
260
278
  })
261
279
  .catch((err) => {
262
280
  console.error("Install failed:", err);
@@ -0,0 +1 @@
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});let e=require("solid-js/web"),t=require("@opencode/plugin/gui"),n=require("solid-js");var r=`.ols-root{--ols-bg-surface:var(--v2-background-bg-layer-01,#141417);--ols-bg-subtle:var(--v2-background-bg-base,#0e0e11);--ols-bg-elevated:var(--v2-background-bg-layer-02,#1c1c21);--ols-bg-pill:var(--v2-background-bg-layer-03,#25252c);--ols-bg-hover:var(--v2-overlay-simple-overlay-hover,#ffffff0d);--ols-bg-pressed:var(--v2-overlay-simple-overlay-pressed,#ffffff17);--ols-border:var(--v2-border-border-muted,#ffffff14);--ols-border-strong:var(--v2-border-border-strong,#ffffff24);--ols-focus:var(--v2-border-border-focus,#3b82f6);--ols-text:var(--v2-text-text-base,#ededf0);--ols-text-muted:var(--v2-text-text-muted,#9ca3af);--ols-text-faint:var(--v2-text-text-faint,#6b7280);--ols-danger:var(--v2-state-fg-danger,#ef4444);--ols-mark-bg:#f59e0b38;--ols-mark-fg:var(--v2-text-text-base,#fde68a);box-sizing:border-box;width:100%;height:100%;min-height:0;color:var(--ols-text);font-family:var(--font-family-text,-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);letter-spacing:-.04px;-webkit-user-select:none;user-select:none;flex-direction:column;font-size:13px;font-weight:440;line-height:1.45;display:flex;overflow:hidden}.ols-root[data-scheme=light]{--ols-bg-surface:var(--v2-background-bg-layer-01,#fff);--ols-bg-subtle:var(--v2-background-bg-base,#f6f6f8);--ols-bg-elevated:var(--v2-background-bg-layer-02,#f0f0f3);--ols-bg-pill:var(--v2-background-bg-layer-03,#e6e6eb);--ols-bg-hover:var(--v2-overlay-simple-overlay-hover,#0000000b);--ols-bg-pressed:var(--v2-overlay-simple-overlay-pressed,#00000014);--ols-border:var(--v2-border-border-muted,#00000014);--ols-border-strong:var(--v2-border-border-strong,#00000024);--ols-text:var(--v2-text-text-base,#161618);--ols-text-muted:var(--v2-text-text-muted,#5c606a);--ols-text-faint:var(--v2-text-text-faint,#8c909a);--ols-mark-bg:#f59e0b47;--ols-mark-fg:#78350f}.ols-root *,.ols-root :before,.ols-root :after{box-sizing:border-box}.ols-root--modal{border-top:1px solid var(--ols-border);border-bottom:1px solid var(--ols-border);flex:1;height:min(64vh,480px);max-height:100%;overflow:hidden}.ols-root--panel{height:100%;min-height:360px}.ols-header{border-bottom:1px solid var(--ols-border);flex-direction:column;flex-shrink:0;gap:8px;padding:10px 16px;display:flex}.ols-root--panel .ols-header{padding:10px 12px}.ols-input-wrap{width:100%;display:flex}.ols-input-wrap [data-component=text-input-v2]{flex:1;width:100%}.ols-controls-bar{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:8px;display:flex}.ols-controls-left{flex-wrap:wrap;align-items:center;gap:6px;min-width:0;display:flex}.ols-controls-right{flex-shrink:0;align-items:center;gap:6px;margin-inline-start:auto;display:flex}.ols-segment{background:var(--ols-bg-elevated);box-shadow:inset 0 0 0 1px var(--ols-border);border-radius:6px;align-items:center;padding:2px;display:inline-flex}.ols-segment-btn{height:20px;color:var(--ols-text-muted);letter-spacing:-.04px;cursor:pointer;background:0 0;border:0;border-radius:4px;align-items:center;gap:5px;padding:0 8px;font-family:inherit;font-size:12px;font-weight:440;transition:background-color 85ms ease-out,color 85ms ease-out;display:inline-flex}.ols-segment-btn:hover{color:var(--ols-text)}.ols-segment-btn:focus-visible{outline:2px solid var(--ols-focus);outline-offset:1px}.ols-segment-btn--active{background:var(--ols-bg-surface);color:var(--ols-text);box-shadow:var(--v2-elevation-button-neutral,0 1px 2px #00000029);font-weight:530}.ols-active-pill{background:var(--ols-bg-pill);height:22px;color:var(--ols-text);cursor:pointer;border:0;border-radius:4px;align-items:center;gap:4px;padding:0 6px 0 8px;font-family:inherit;font-size:12px;font-weight:440;transition:background-color 85ms ease-out;display:inline-flex}.ols-active-pill:hover{background:var(--ols-bg-pressed)}.ols-active-pill:focus-visible{outline:2px solid var(--ols-focus);outline-offset:1px}.ols-error-pill{height:22px;color:var(--ols-danger);background:#ef44441f;border-radius:4px;align-items:center;padding:0 8px;font-size:12px;font-weight:530;display:inline-flex}.ols-status-count{color:var(--ols-text-faint);font-variant-numeric:tabular-nums;align-items:center;font-size:12px;display:inline-flex}.ols-split{flex:1;grid-template-columns:minmax(260px,38%) minmax(0,1fr);min-height:0;display:grid;position:relative;overflow:hidden}.ols-loading-center{z-index:20;-webkit-backdrop-filter:blur(1.5px);backdrop-filter:blur(1.5px);pointer-events:none;background:#0e0e116b;justify-content:center;align-items:center;display:flex;position:absolute;inset:0}.ols-root[data-scheme=light] .ols-loading-center{background:#f6f6f885}.ols-loading-pill{background:var(--ols-bg-elevated);border:1px solid var(--ols-border-strong);color:var(--ols-text);border-radius:999px;align-items:center;gap:8px;padding:8px 14px;font-size:12px;font-weight:530;display:inline-flex;box-shadow:0 4px 16px #00000047}.ols-spinner{border:2px solid var(--ols-border-strong);border-top-color:var(--ols-focus);border-radius:50%;width:14px;height:14px;animation:.65s linear infinite ols-spin}@keyframes ols-spin{to{transform:rotate(360deg)}}.ols-root--panel .ols-split{grid-template-rows:minmax(170px,44%) minmax(0,1fr);grid-template-columns:1fr}.ols-column{flex-direction:column;min-width:0;min-height:0;display:flex;overflow:hidden}.ols-column--list{border-right:1px solid var(--ols-border);background:var(--ols-bg-subtle)}.ols-root--panel .ols-column--list{border-right:0;border-bottom:1px solid var(--ols-border)}.ols-column--detail{background:var(--ols-bg-surface)}.ols-list-scroll,.ols-detail-scroll{flex:1;min-height:0;overflow:hidden auto}.ols-list-scroll{flex-direction:column;gap:2px;padding:6px;display:flex}.ols-row{width:100%;color:var(--ols-text);text-align:left;cursor:pointer;background:0 0;border:0;border-radius:6px;flex-direction:column;gap:3px;padding:8px 10px;font-family:inherit;transition:background-color 65ms ease-out;display:flex}.ols-row:hover{background:var(--ols-bg-hover)}.ols-row:focus-visible{outline:2px solid var(--ols-focus);outline-offset:-2px}.ols-row--selected,.ols-row--selected:hover{background:var(--ols-bg-pressed)}.ols-row-top{justify-content:space-between;align-items:baseline;gap:8px;min-width:0;display:flex}.ols-row-title{color:var(--ols-text);white-space:nowrap;text-overflow:ellipsis;flex:1;min-width:0;font-size:13px;font-weight:530;overflow:hidden}.ols-row-time{color:var(--ols-text-faint);font-variant-numeric:tabular-nums;flex-shrink:0;font-size:11px}.ols-row-snippet{color:var(--ols-text-muted);-webkit-line-clamp:2;overflow-wrap:anywhere;-webkit-box-orient:vertical;font-size:12px;line-height:1.38;display:-webkit-box;overflow:hidden}.ols-row-meta{color:var(--ols-text-faint);font-variant-numeric:tabular-nums;white-space:nowrap;align-items:center;gap:6px;margin-top:2px;font-size:11px;display:flex;overflow:hidden}.ols-row-hit-badge{background:var(--ols-bg-pill);height:16px;color:var(--ols-text-muted);letter-spacing:.01em;border-radius:3px;align-items:center;padding:0 5px;font-size:10px;font-weight:530;display:inline-flex}.ols-row-folder{color:var(--ols-text-muted);text-overflow:ellipsis;overflow:hidden}.ols-detail-header{border-bottom:1px solid var(--ols-border);flex-shrink:0;justify-content:space-between;align-items:center;gap:12px;padding:12px 16px;display:flex}.ols-detail-heading{flex-direction:column;flex:1;gap:2px;min-width:0;display:flex}.ols-detail-title{color:var(--ols-text);white-space:nowrap;text-overflow:ellipsis;font-size:14px;font-weight:530;overflow:hidden}.ols-detail-meta{color:var(--ols-text-faint);white-space:nowrap;text-overflow:ellipsis;align-items:center;gap:6px;font-size:12px;display:flex;overflow:hidden}.ols-detail-actions{flex-shrink:0;align-items:center;gap:6px;display:flex}.ols-quick-bar{border-bottom:1px solid var(--ols-border);background:var(--ols-bg-subtle);flex-wrap:wrap;flex-shrink:0;align-items:center;gap:6px;padding:7px 16px;display:flex}.ols-quick-label{color:var(--ols-text-faint);font-size:11px}.ols-quick-chip{background:var(--ols-bg-elevated);height:20px;box-shadow:inset 0 0 0 1px var(--ols-border);color:var(--ols-text-muted);font-family:var(--font-family-mono,ui-monospace, SFMono-Regular, Consolas, monospace);cursor:pointer;border:0;border-radius:4px;align-items:center;padding:0 7px;font-size:11px;transition:background-color 65ms ease-out,color 65ms ease-out;display:inline-flex}.ols-quick-chip:hover{background:var(--ols-bg-hover);color:var(--ols-text)}.ols-timeline{divide-y:1px solid var(--ols-border);flex-direction:column;display:flex}.ols-turn{border-bottom:1px solid var(--ols-border);cursor:pointer;flex-direction:column;gap:4px;padding:12px 16px;transition:background-color 65ms ease-out;display:flex}.ols-turn:hover{background:var(--ols-bg-hover)}.ols-turn--selected{background:var(--ols-bg-pressed)}.ols-turn-header{align-items:center;gap:6px;font-size:12px;display:flex}.ols-turn-author{color:var(--ols-text);font-weight:530}.ols-turn-author--user{color:var(--ols-text)}.ols-turn-author--assistant{color:var(--ols-text-muted)}.ols-turn-author--shell{color:var(--v2-state-fg-warning,#f59e0b)}.ols-turn-chip{background:var(--ols-bg-pill);height:16px;color:var(--ols-text-muted);font-family:var(--font-family-mono,ui-monospace, SFMono-Regular, Consolas, monospace);border-radius:3px;align-items:center;padding:0 5px;font-size:10px;display:inline-flex}.ols-turn-time{color:var(--ols-text-faint);font-variant-numeric:tabular-nums;margin-inline-start:auto;font-size:11px}.ols-turn-body{color:var(--ols-text-muted);white-space:pre-wrap;overflow-wrap:anywhere;-webkit-user-select:text;user-select:text;font-size:13px;line-height:1.5}.ols-mark{background:var(--ols-mark-bg);color:var(--ols-mark-fg);border-radius:2px;padding:0 2px;font-weight:530}.ols-empty{text-align:center;flex-direction:column;flex:1;justify-content:center;align-items:center;gap:4px;padding:36px 20px;display:flex}.ols-empty-title{color:var(--ols-text);font-size:13px;font-weight:530}.ols-empty-sub{color:var(--ols-text-faint);max-width:280px;font-size:12px}.ols-inline-link{color:var(--ols-text);font:inherit;text-underline-offset:2px;cursor:pointer;background:0 0;border:0;padding:0;font-weight:530;text-decoration:underline}.ols-dialog-footer{justify-content:space-between;align-items:center;gap:12px;width:100%;display:flex}.ols-dialog-shortcuts{flex-wrap:wrap;align-items:center;gap:14px;display:flex}.ols-shortcut-item{color:var(--ols-text-faint);align-items:center;gap:5px;font-size:12px;display:inline-flex}@media (width<=720px){.ols-split{grid-template-rows:minmax(160px,42%) minmax(0,1fr);grid-template-columns:1fr}.ols-column--list{border-right:0;border-bottom:1px solid var(--ols-border)}}[data-component=home-session-search],[data-component=home-session-search] label,[data-component=home-session-search] input{cursor:pointer}#home-session-search-results{display:none}`,i={id:`opencode-local-search`,methods:{query:{input:{$schema:`https://json-schema.org/draft/2020-12/schema`,type:`object`,properties:{query:{type:`string`},sort:{type:`string`,enum:[`updated`,`relevance`,`newest`,`oldest`,`title`,`context`,`tokens`]},scope:{type:`string`,enum:[`all`,`project`]},currentDirectory:{type:`string`},role:{type:`string`,enum:[`all`,`user`,`assistant`,`shell`]},datePreset:{type:`string`,enum:[`all`,`today`,`yesterday`,`7d`,`30d`]},mode:{type:`string`,enum:[`smart`,`fuzzy`,`regex`]},limit:{type:`number`},forceReload:{type:`boolean`}},required:[`query`],additionalProperties:!1},output:{$schema:`https://json-schema.org/draft/2020-12/schema`,type:`object`,additionalProperties:!0}}},events:{}},a={updated:`Recently updated`,relevance:`Relevance`,newest:`Newest created`,oldest:`Oldest created`,title:`Title A–Z`,context:`Latest context size`,tokens:`Total tokens used`},o=(0,e.template)(`<mark class=ols-mark>`),s=(0,e.template)(`<button type=button class=ols-active-pill title="Click to reset search mode"><span>`),c=(0,e.template)(`<button type=button class=ols-active-pill title="Click to reset role filter"><span>`),l=(0,e.template)(`<button type=button class=ols-active-pill title="Click to reset time filter"><span>`),u=(0,e.template)(`<div class=ols-loading-center role=status aria-live=polite><div class=ols-loading-pill><span class=ols-spinner aria-hidden=true></span><span>Searching...`),d=(0,e.template)(`<div class=ols-split><div><div class=ols-list-scroll></div></div><div>`),f=(0,e.template)(`<div><div class=ols-header><div class=ols-input-wrap></div><div class=ols-controls-bar><div class=ols-controls-left><div class=ols-segment role=group aria-label="Search scope"><button type=button><span></span></button><button type=button><span>All workspaces</span></button></div></div><div class=ols-controls-right><span class=ols-status-count>`),ee=(0,e.template)(`<span class=ols-error-pill>`),te=(0,e.template)(`<div class=ols-empty><div class=ols-empty-title>Unable to search sessions</div><div class=ols-empty-sub>`),ne=(0,e.template)(`<button type=button class=ols-inline-link>All workspaces`),re=(0,e.template)(`<div class=ols-empty><div class=ols-empty-title>No matching sessions</div><div class=ols-empty-sub>`),ie=(0,e.template)(`<div class=ols-row-snippet>`),ae=(0,e.template)(`<span class=ols-row-hit-badge>Archived`),oe=(0,e.template)(`<span>: `),se=(0,e.template)(`<span class=ols-row-hit-badge>`),ce=(0,e.template)(`<span class=ols-row-folder>`),le=(0,e.template)(`<button type=button><div class=ols-row-top><span class=ols-row-title></span><span class=ols-row-time></span></div><div class=ols-row-meta><span> messages`),ue=(0,e.template)(`<div class=ols-empty><div class=ols-empty-sub>Select a session to inspect conversation matches.`),de=(0,e.template)(`<span>Archived`),fe=(0,e.template)(`<div class=ols-detail-header><div class=ols-detail-heading><div class=ols-detail-title></div><div class=ols-detail-meta><span></span><span>·</span><span></span></div></div><div class=ols-detail-actions>`),pe=(0,e.template)(`<div class=ols-quick-bar><span class=ols-quick-label>Try:</span><button type=button class=ols-quick-chip>role:user</button><button type=button class=ols-quick-chip>tool:shell</button><button type=button class=ols-quick-chip>in:title</button><button type=button class=ols-quick-chip>since:7d`),p=(0,e.template)(`<div class=ols-timeline>`),me=(0,e.template)(`<div class=ols-detail-scroll>`),he=(0,e.template)(`<span class=ols-turn-chip>`),ge=(0,e.template)(`<div class=ols-turn><div class=ols-turn-header><span></span><span class=ols-turn-time></span></div><div class=ols-turn-body>`),_e=(0,e.template)(`<span class=ols-turn-chip>file`),ve=(0,e.template)(`<span class=ols-turn-chip>~`),ye=(0,e.template)(`<div><div class=ols-turn-header><span></span><span class=ols-turn-time></span></div><div class=ols-turn-body>`),m=[`all`,`user`,`assistant`,`shell`],h=[`all`,`today`,`yesterday`,`7d`,`30d`],g=[`smart`,`fuzzy`,`regex`],_={all:`Any time`,today:`Today`,yesterday:`Yesterday`,"7d":`Last 7 days`,"30d":`Last 30 days`},be={smart:`Smart`,fuzzy:`Fuzzy`,regex:`Regex`},xe={all:`All roles`,user:`User`,assistant:`Assistant`,shell:`Shell`};function v(e,t=Date.now()){if(!e||e<=0)return``;let n=Math.max(0,Math.floor((t-e)/1e3));if(n<60)return`just now`;let r=Math.floor(n/60);if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);if(a<30)return`${a}d ago`;let o=new Date(e);return`${o.getFullYear()}-${String(o.getMonth()+1).padStart(2,`0`)}-${String(o.getDate()).padStart(2,`0`)}`}function Se(e){if(!e)return`unknown`;let t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)} ${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`}function Ce(e){if(!e)return`Global`;let t=e.replace(/\\/g,`/`).split(`/`).filter(Boolean);return t.length<=2?t.join(`/`):`${t.slice(-2).join(`/`)}`}function y(e,t,n,r){if(!e)return[{text:``,match:!1}];if(n)try{let t=r?.includes(`g`)?r:`${r??`i`}g`,i=new RegExp(n,t),a=[],o=0,s,c=0;for(;(s=i.exec(e))!==null&&c++<40;)s[0].length===0?i.lastIndex++:(s.index>o&&a.push({text:e.slice(o,s.index),match:!1}),a.push({text:s[0],match:!0}),o=s.index+s[0].length);return o<e.length&&a.push({text:e.slice(o),match:!1}),a.length>0?a:[{text:e,match:!1}]}catch{return[{text:e,match:!1}]}let i=t.map(e=>e.trim().toLowerCase()).filter(e=>e.length>0).sort((e,t)=>t.length-e.length);if(i.length===0)return[{text:e,match:!1}];let a=e.toLowerCase(),o=[],s=0;for(;s<e.length;){let t=-1,n=0;for(let e of i){let r=a.indexOf(e,s);r!==-1&&(t===-1||r<t)&&(t=r,n=e.length)}if(t===-1){o.push({text:e.slice(s),match:!1});break}t>s&&o.push({text:e.slice(s,t),match:!1}),o.push({text:e.slice(t,t+n),match:!0}),s=t+n}return o.length>0?o:[{text:e,match:!1}]}function b(t){let r=(0,n.createMemo)(()=>y(t.text,t.terms,t.regexPattern,t.regexFlags));return(0,e.createComponent)(n.For,{get each(){return r()},children:t=>t.match?(()=>{var n=o();return(0,e.insert)(n,()=>t.text),n})():t.text})}function x(e){let t=e.sessions.current();if(t?.server?.id)return t.server.id;let n=e.servers.list();for(let t of n)if(e.servers.get(t)?.builtin)return t;return n[0]??`sidecar`}function S(e){return e===`user`?`You`:e===`assistant`?`Assistant`:e===`shell`?`Command`:e===`title`?`Title`:e}var[C,w]=(0,n.createSignal)(``);function T(t){let r=t.ctx.ui,[o,y]=(0,n.createSignal)(t.initialQuery??``),[w,T]=(0,n.createSignal)(t.ctx.sessions.current()?.directory?`project`:`all`),[E,D]=(0,n.createSignal)(`all`),[O,k]=(0,n.createSignal)(`all`),[A,j]=(0,n.createSignal)(`smart`),[M,we]=(0,n.createSignal)(`updated`),[N,P]=(0,n.createSignal)(!1),[F,I]=(0,n.createSignal)(0),[L,R]=(0,n.createSignal)(0),[z,B]=(0,n.createSignal)(`sessions`),[V,H]=(0,n.createSignal)(!0),[Te,Ee]=(0,n.createSignal)(!1),[De,Oe]=(0,n.createSignal)(null),[ke,Ae]=(0,n.createSignal)(0),[U,je]=(0,n.createSignal)([]),[W,Me]=(0,n.createSignal)(null);(0,n.createEffect)(()=>{let e=C();e&&y(e)});let G=0,K,q=(0,n.createMemo)(()=>t.ctx.sessions.current()?.directory??``),Ne=(0,n.createMemo)(()=>t.ctx.appearance.mode());async function J(e=!1){let n=++G;e&&Ee(!0),H(!0),Oe(null);try{let r=await(t.ctx.sessions.current()?.server?.client??t.ctx.servers.get(x(t.ctx))?.client??t.ctx.client).rpc(i).query({query:o(),scope:w(),currentDirectory:q(),role:E(),datePreset:O(),mode:A(),sort:M(),limit:60,forceReload:e});if(n!==G)return;Ae(r.totalSessions),je(r.results),Me(r.parsed),I(e=>Math.max(0,Math.min(e,Math.max(0,r.results.length-1)))),R(0),e&&t.ctx.toast.show({variant:`success`,title:`Refreshed ${r.totalSessions} sessions`})}catch(e){if(n!==G)return;Oe(e instanceof Error?e.message:`Failed to query session index`)}finally{n===G&&(H(!1),Ee(!1))}}(0,n.createEffect)(()=>{o(),w(),E(),O(),A(),M(),q(),K&&clearTimeout(K),K=setTimeout(()=>{J(!1)},16)}),(0,n.onCleanup)(()=>{K&&clearTimeout(K)});let Y=(0,n.createMemo)(()=>U()[F()]??U()[0]),X=(0,n.createMemo)(()=>{let e=W(),t=e?[...e.terms,...e.fuzzyTerms]:[],n=Y()?.matches[L()]?.matchedTerm;return n&&!t.includes(n)&&t.push(n),t}),Z=(0,n.createMemo)(()=>{let e=0;return E()!==`all`&&e++,O()!==`all`&&e++,A()!==`smart`&&e++,e}),Pe=(0,n.createMemo)(()=>[{type:`group`,label:`Search Mode`,items:g.map(e=>({label:be[e],icon:A()===e?`check-small`:void 0,onSelect:()=>{j(e),I(0)}}))},{type:`separator`},{type:`group`,label:`Message Role`,items:m.map(e=>({label:xe[e],icon:E()===e?`check-small`:void 0,onSelect:()=>{D(e),I(0)}}))},{type:`separator`},{type:`group`,label:`Time Range`,items:h.map(e=>({label:_[e],icon:O()===e?`check-small`:void 0,onSelect:()=>{k(e),I(0)}}))},{type:`separator`},{label:`Reset filters`,disabled:Z()===0,onSelect:()=>{j(`smart`),D(`all`),k(`all`),I(0)}}]);function Fe(){T(e=>e===`project`?`all`:`project`),I(0)}function Ie(){D(e=>m[(m.indexOf(e)+1)%m.length]??`all`),I(0)}function Le(){k(e=>h[(h.indexOf(e)+1)%h.length]??`all`),I(0)}function Re(){j(e=>g[(g.indexOf(e)+1)%g.length]??`smart`),I(0)}function Q(e){if(!e)return;let n=x(t.ctx);t.ctx.tabs.open({server:n,id:e.id},{focus:!0}),t.onClose?.()}async function ze(e){e&&(await t.ctx.system.copy(e.id),t.ctx.toast.show({variant:`success`,title:`Copied session ID`,description:e.id}))}async function Be(e){if(!N()){P(!0);try{await(t.ctx.sessions.current()?.server?.client??t.ctx.servers.get(x(t.ctx))?.client??t.ctx.client).session.update({sessionID:e.id,archived:!1}),await J(!0)}catch(e){t.ctx.toast.show({variant:`error`,title:`Unable to unarchive session`,description:e instanceof Error?e.message:String(e)})}finally{P(!1)}}}function $(e){let t=o().trim();y(t?`${t} ${e}`:e)}function Ve(e){if((e.ctrlKey||e.altKey)&&!e.shiftKey){let t=e.key.toLowerCase();if(t===`p`){e.preventDefault(),Fe();return}if(t===`g`){e.preventDefault(),Ie();return}if(t===`t`){e.preventDefault(),Le();return}if(t===`r`){e.preventDefault(),Re();return}if(t===`l`){e.preventDefault(),J(!0);return}}if(e.key===`Tab`){e.preventDefault(),B(e=>e===`sessions`?`matches`:`sessions`);return}let t=U().length,n=Y()?.matches.length??0;e.key===`ArrowDown`?(e.preventDefault(),z()===`matches`&&n>0?R(e=>Math.min(n-1,e+1)):t>0&&(I(e=>Math.min(t-1,e+1)),R(0))):e.key===`ArrowUp`?(e.preventDefault(),z()===`matches`&&n>0?R(e=>Math.max(0,e-1)):t>0&&(I(e=>Math.max(0,e-1)),R(0))):e.key===`PageDown`?(e.preventDefault(),t>0&&(I(e=>Math.min(t-1,e+8)),R(0))):e.key===`PageUp`?(e.preventDefault(),t>0&&(I(e=>Math.max(0,e-8)),R(0))):e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),Q(Y()))}return(()=>{var i=f(),m=i.firstChild.firstChild,h=m.nextSibling.firstChild,g=h.firstChild.firstChild,x=g.firstChild,C=g.nextSibling,P=h.nextSibling,H=P.firstChild;return i.$$keydown=Ve,(0,e.insert)(m,(0,e.createComponent)(r.TextInput,{type:`search`,size:`large`,label:`Search session history`,get value(){return o()},onInput:e=>{y(e),I(0),R(0)},onSubmit:()=>Q(Y()),placeholder:`Search conversations, "exact phrase", fuzzy~, /regex/i, role:user, tool:shell...`,get invalid(){return!!W()?.regexError},autofocus:!0})),g.$$click=()=>{T(`project`),I(0)},(0,e.insert)(g,(0,e.createComponent)(r.Icon,{name:`folder`,size:`small`}),x),(0,e.insert)(x,(()=>{var t=(0,e.memo)(()=>!!q());return()=>t()?Ce(q()):`Project`})()),C.$$click=()=>{T(`all`),I(0)},(0,e.insert)(h,(0,e.createComponent)(r.Menu,{get label(){return`Sort: ${a[M()]}`},trigger:`button`,get items(){return Object.entries(a).map(([e,t])=>({label:t,icon:M()===e?`check-small`:void 0,onSelect:()=>{we(e),I(0)}}))}}),null),(0,e.insert)(h,(0,e.createComponent)(r.Menu,{get label(){return(0,e.memo)(()=>Z()>0)()?`Filters (${Z()})`:`Filters`},icon:`sliders`,trigger:`button`,get items(){return Pe()}}),null),(0,e.insert)(h,(0,e.createComponent)(n.Show,{get when(){return A()!==`smart`},get children(){var t=s(),n=t.firstChild;return t.$$click=()=>j(`smart`),(0,e.insert)(n,()=>be[A()]),(0,e.insert)(t,(0,e.createComponent)(r.Icon,{name:`close-small`,size:`small`}),null),t}}),null),(0,e.insert)(h,(0,e.createComponent)(n.Show,{get when(){return E()!==`all`},get children(){var t=c(),n=t.firstChild;return t.$$click=()=>D(`all`),(0,e.insert)(n,()=>xe[E()]),(0,e.insert)(t,(0,e.createComponent)(r.Icon,{name:`close-small`,size:`small`}),null),t}}),null),(0,e.insert)(h,(0,e.createComponent)(n.Show,{get when(){return O()!==`all`},get children(){var t=l(),n=t.firstChild;return t.$$click=()=>k(`all`),(0,e.insert)(n,()=>_[O()]),(0,e.insert)(t,(0,e.createComponent)(r.Icon,{name:`close-small`,size:`small`}),null),t}}),null),(0,e.insert)(h,(0,e.createComponent)(n.Show,{get when(){return W()?.regexError},children:t=>(()=>{var n=ee();return(0,e.insert)(n,t),n})()}),null),(0,e.insert)(H,(0,e.createComponent)(n.Show,{get when(){return!V()},get fallback(){return(0,e.createComponent)(r.Loader,{size:`small`})},get children(){return[(0,e.memo)(()=>U().length),` of `,(0,e.memo)(()=>ke()),` sessions`]}})),(0,e.insert)(P,(0,e.createComponent)(r.Tooltip,{value:`Refresh index`,keys:[`Ctrl`,`L`],get children(){return(0,e.createComponent)(r.IconButton,{icon:`refresh`,label:`Refresh index`,variant:`ghost`,size:`small`,get busy(){return Te()},onClick:()=>void J(!0)})}}),null),(0,e.insert)(i,(0,e.createComponent)(n.Show,{get when(){return De()},children:t=>(()=>{var n=te(),r=n.firstChild.nextSibling;return(0,e.insert)(r,t),n})()}),null),(0,e.insert)(i,(0,e.createComponent)(n.Show,{get when(){return!De()},get children(){var i=d(),a=i.firstChild,s=a.firstChild,c=a.nextSibling;return(0,e.insert)(i,(0,e.createComponent)(n.Show,{get when(){return V()},get children(){return u()}}),a),a.$$click=()=>B(`sessions`),(0,e.insert)(s,(0,e.createComponent)(n.Show,{get when(){return U().length>0},get fallback(){return(0,e.createComponent)(n.Show,{get when(){return!V()},get children(){var t=re(),r=t.firstChild.nextSibling;return(0,e.insert)(r,(0,e.createComponent)(n.Show,{get when(){return w()===`project`},fallback:`Try Fuzzy mode or fewer search terms.`,get children(){return[`No hits in this workspace. Switch to`,` `,(()=>{var e=ne();return e.$$click=Fe,e})(),` `,`to search everywhere.`]}})),t}})},get children(){return(0,e.createComponent)(n.For,{get each(){return U()},children:(t,r)=>{let i=()=>r()===F();return(()=>{var a=le(),s=a.firstChild,c=s.firstChild,l=c.nextSibling,u=s.nextSibling,d=u.firstChild,f=d.firstChild;return a.$$dblclick=()=>Q(t),a.$$click=()=>{I(r()),R(0),B(`sessions`)},(0,e.insert)(c,(0,e.createComponent)(b,{get text(){return t.title||`Untitled session`},get terms(){return X()},get regexPattern(){return W()?.regexPattern},get regexFlags(){return W()?.regexFlags}})),(0,e.insert)(l,()=>v(t.timeUpdated)),(0,e.insert)(a,(0,e.createComponent)(n.Show,{get when(){return t.bestSnippet},get children(){var n=ie();return(0,e.insert)(n,(0,e.createComponent)(b,{get text(){return t.bestSnippet},get terms(){return X()},get regexPattern(){return W()?.regexPattern},get regexFlags(){return W()?.regexFlags}})),n}}),u),(0,e.insert)(u,(0,e.createComponent)(n.Show,{get when(){return t.archived},get children(){return ae()}}),d),(0,e.insert)(u,(0,e.createComponent)(n.Show,{get when(){return M()===`context`||M()===`tokens`},get children(){var n=oe(),r=n.firstChild;return(0,e.insert)(n,()=>M()===`context`?`Context`:`Total`,r),(0,e.insert)(n,()=>(M()===`context`?t.contextTokens:t.totalTokens)?.toLocaleString()??`Not recorded`,null),n}}),d),(0,e.insert)(u,(0,e.createComponent)(n.Show,{get when(){return o().trim().length>0},get children(){var n=se();return(0,e.insert)(n,()=>t.matchBadge),n}}),d),(0,e.insert)(u,(0,e.createComponent)(n.Show,{get when(){return(0,e.memo)(()=>w()===`all`)()&&t.directory},get children(){var n=ce();return(0,e.insert)(n,()=>Ce(t.directory)),n}}),d),(0,e.insert)(d,()=>t.entryCount,f),(0,e.effect)(()=>(0,e.className)(a,`ols-row ${i()?`ols-row--selected`:``}`)),a})()}})}})),c.$$click=()=>B(`matches`),(0,e.insert)(c,(0,e.createComponent)(n.Show,{get when(){return Y()},get fallback(){return ue()},children:i=>[(()=>{var t=fe(),a=t.firstChild,o=a.firstChild,s=o.nextSibling,c=s.firstChild,l=c.nextSibling.nextSibling,u=a.nextSibling;return(0,e.insert)(o,()=>i().title),(0,e.insert)(s,(0,e.createComponent)(n.Show,{get when(){return i().archived},get children(){return de()}}),c),(0,e.insert)(c,()=>i().directory||`Global`),(0,e.insert)(l,()=>Se(i().timeUpdated)),(0,e.insert)(u,(0,e.createComponent)(n.Show,{get when(){return i().archived},get children(){return(0,e.createComponent)(r.Button,{size:`small`,get busy(){return N()},onClick:()=>void Be(i()),children:`Unarchive`})}}),null),(0,e.insert)(u,(0,e.createComponent)(r.Tooltip,{value:`Copy session ID`,get children(){return(0,e.createComponent)(r.IconButton,{icon:`copy`,label:`Copy session ID`,variant:`ghost`,size:`small`,onClick:()=>void ze(i())})}}),null),(0,e.insert)(u,(0,e.createComponent)(r.Button,{variant:`contrast`,size:`small`,icon:`square-arrow-top-right`,onClick:()=>Q(i()),children:`Open`}),null),t})(),(0,e.createComponent)(n.Show,{get when(){return(0,e.memo)(()=>o().trim().length===0)()&&t.variant===`modal`},get children(){var e=pe(),t=e.firstChild.nextSibling,n=t.nextSibling,r=n.nextSibling,i=r.nextSibling;return t.$$click=()=>$(`role:user`),n.$$click=()=>$(`tool:shell`),r.$$click=()=>$(`in:title`),i.$$click=()=>$(`since:7d`),e}}),(()=>{var t=me();return(0,e.insert)(t,(0,e.createComponent)(n.Show,{get when(){return i().matches.length>0},get fallback(){return(()=>{var t=p();return(0,e.insert)(t,(0,e.createComponent)(n.For,{get each(){return i().recentEntries},children:t=>(()=>{var r=ge(),a=r.firstChild,o=a.firstChild,s=o.nextSibling,c=a.nextSibling;return r.$$click=()=>Q(i()),(0,e.insert)(o,()=>S(t.role)),(0,e.insert)(a,(0,e.createComponent)(n.Show,{get when(){return t.toolName},get children(){var n=he();return(0,e.insert)(n,()=>t.toolName),n}}),s),(0,e.insert)(s,()=>v(t.timeCreated)),(0,e.insert)(c,()=>t.text),(0,e.effect)(()=>(0,e.className)(o,`ols-turn-author ols-turn-author--${t.role}`)),r})()})),t})()},get children(){var t=p();return(0,e.insert)(t,(0,e.createComponent)(n.For,{get each(){return i().matches},children:(t,r)=>{let a=()=>z()===`matches`&&r()===L();return(()=>{var o=ye(),s=o.firstChild,c=s.firstChild,l=c.nextSibling,u=s.nextSibling;return o.$$dblclick=()=>Q(i()),o.$$click=()=>{B(`matches`),R(r())},(0,e.insert)(c,()=>S(t.role)),(0,e.insert)(s,(0,e.createComponent)(n.Show,{get when(){return(0,e.memo)(()=>t.kind===`tool`)()&&t.toolName},get children(){var n=he();return(0,e.insert)(n,()=>t.toolName),n}}),l),(0,e.insert)(s,(0,e.createComponent)(n.Show,{get when(){return t.kind===`filepath`},get children(){return _e()}}),l),(0,e.insert)(s,(0,e.createComponent)(n.Show,{get when(){return t.kind===`fuzzy`},get children(){var n=ve();return n.firstChild,(0,e.insert)(n,()=>t.matchedTerm,null),n}}),l),(0,e.insert)(l,()=>v(t.timeCreated)),(0,e.insert)(u,(0,e.createComponent)(b,{get text(){return t.snippet},get terms(){return X()},get regexPattern(){return W()?.regexPattern},get regexFlags(){return W()?.regexFlags}})),(0,e.effect)(n=>{var r=`ols-turn ${a()?`ols-turn--selected`:``}`,i=`ols-turn-author ols-turn-author--${t.role}`;return r!==n.e&&(0,e.className)(o,n.e=r),i!==n.t&&(0,e.className)(c,n.t=i),n},{e:void 0,t:void 0}),o})()}})),t}})),t})()]})),(0,e.effect)(t=>{var n=`ols-column ols-column--list ${z()===`sessions`?`ols-column--active`:``}`,r=`ols-column ols-column--detail ${z()===`matches`?`ols-column--active`:``}`;return n!==t.e&&(0,e.className)(a,t.e=n),r!==t.t&&(0,e.className)(c,t.t=r),t},{e:void 0,t:void 0}),i}}),null),(0,e.effect)(n=>{var r=`ols-root ols-root--${t.variant}`,a=Ne(),o=`ols-segment-btn ${w()===`project`?`ols-segment-btn--active`:``}`,s=q()?`Current project (${q()})`:`Current project`,c=`ols-segment-btn ${w()===`all`?`ols-segment-btn--active`:``}`;return r!==n.e&&(0,e.className)(i,n.e=r),a!==n.t&&(0,e.setAttribute)(i,`data-scheme`,n.t=a),o!==n.a&&(0,e.className)(g,n.a=o),s!==n.o&&(0,e.setAttribute)(g,`title`,n.o=s),c!==n.i&&(0,e.className)(C,n.i=c),n},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),i})()}var E=t.Plugin.define({i18n:{en:{"search.title":`Search`,"search.command":`Search session history...`,"search.panel":`Search`}},setup(i){let a=i.ui;i.add(t.Style,r);let o;function s(t=``){w(t);let r=i.sessions.current();if(r){o?.close();try{i.layout.open(`${i.id}:search`,r)}catch{}}else{if(o)return;o=i.dialogs.open(r=>((0,n.onCleanup)(()=>{o=void 0}),(0,e.createComponent)(a.Dialog,{title:`Search`,size:`x-large`,get children(){return(0,e.createComponent)(T,{ctx:i,variant:`modal`,initialQuery:t,get onClose(){return r.close}})}})))}}if(i.add(t.Command,()=>({id:`search`,title:`Search session history...`,description:`Full-text, fuzzy, regex, tool, and file search across all session conversations`,keywords:`find history messages conversation regex fuzzy search grep`,group:`Session`,section:`session`,bind:`mod+shift+f`,slash:{name:`search`,arguments:!0},featured:!0,run(e){s(typeof e==`string`?e:``)}})),i.add(t.Command,()=>({id:`search-panel`,title:`Toggle session search panel`,description:`Open or close the Session Search side panel`,keywords:`panel sidebar search history`,group:`Session`,section:`session`,bind:`mod+alt+f`,run(){let e=i.sessions.current();e?i.layout.toggle(`${i.id}:search`,e):s(``)}})),typeof document<`u`){let e=e=>{let t=e.closest(`button`);if(!t||t.closest(`.ols-root`))return!1;if(t.getAttribute(`data-action`)===`vertical-tabs-search`)return!0;if(!t.closest(`[data-slot="titlebar-v2"]`)||t.closest(`[data-titlebar-plugin-item]`))return!1;if((t.getAttribute(`aria-label`)??``).toLowerCase().includes(`search`))return!0;let n=t.querySelector(`svg[data-slot="icon-svg"] use`);return(n?.getAttribute(`href`)??n?.getAttribute(`xlink:href`)??``).includes(`magnifying-glass`)},t=t=>{let n=t.target;if(!(n instanceof Element))return;if(e(n)){t.preventDefault(),t.stopPropagation(),s(``);return}let r=n.closest(`[data-component="home-session-search"]`);if(r){t.preventDefault(),t.stopPropagation();let e=r.querySelector(`input`),n=e instanceof HTMLInputElement?e.value:``;e instanceof HTMLElement&&e.blur(),s(n)}},r=e=>{let t=e.target;if(!(t instanceof Element)||!t.closest(`[data-component="home-session-search"]`))return;let n=t instanceof HTMLInputElement?t.value:``;t instanceof HTMLElement&&t.blur(),s(n)};document.addEventListener(`click`,t,!0),document.addEventListener(`focusin`,r,!0);let i=()=>{let e=document.querySelectorAll(`button[data-action="vertical-tabs-search"]`);for(let t of e){for(let e of t.querySelectorAll(`span`))(e.textContent?.trim().toLowerCase()??``)===`search sessions`?(e.textContent=`Search`,e.classList.add(`whitespace-nowrap`)):(e.classList.contains(`ms-auto`)||e.querySelector(`bdi, kbd`))&&e.remove();t.getAttribute(`aria-label`)?.toLowerCase()===`search sessions`&&t.setAttribute(`aria-label`,`Search`),t.getAttribute(`title`)?.toLowerCase()===`search sessions`&&t.setAttribute(`title`,`Search`)}};i(),setTimeout(i,50);let a=new WeakSet,o=new MutationObserver(()=>{i();let e=document.querySelector(`.command-palette input[placeholder="Search sessions"], .command-palette-dialog input[placeholder="Search sessions..."]`);if(e&&!a.has(e)){a.add(e);let t=e.value||``;e.dispatchEvent(new KeyboardEvent(`keydown`,{key:`Escape`,code:`Escape`,bubbles:!0,cancelable:!0})),s(t)}});document.body&&o.observe(document.body,{childList:!0,subtree:!0}),(0,n.onCleanup)(()=>{document.removeEventListener(`click`,t,!0),document.removeEventListener(`focusin`,r,!0),o.disconnect()})}let c={id:`search`,get title(){return i.t(`search.panel`)},closable:`compact`};i.add(t.Panel,{id:`search`,region:`side`,list:e=>e.open.includes(`search`)?[c]:[],render:()=>(0,e.createComponent)(T,{ctx:i,variant:`panel`})}),i.add(t.MenuItem,()=>{let e=i.sessions.current();return{menu:`session.panel`,id:`search`,title:`Search`,description:`Search conversation history`,icon:`magnifying-glass`,keybind:`${i.id}.search-panel`,opened:!!e&&i.layout.state(`${i.id}:search`,e)!==`closed`,run:()=>{let e=i.sessions.current();e?i.layout.open(`${i.id}:search`,e):s(``)}}})}});(0,e.delegateEvents)([`keydown`,`click`,`dblclick`]),exports.default=E;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nandoblanco/opencode-local-search",
3
- "version": "1.0.2",
3
+ "version": "1.2.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -10,7 +10,9 @@
10
10
  "exports": {
11
11
  ".": "./src/index.ts",
12
12
  "./server": "./src/server.ts",
13
- "./tui": "./src/tui.ts"
13
+ "./tui": "./src/tui.ts",
14
+ "./gui-experimental": "./dist/gui-experimental.cjs",
15
+ "./rpc": "./src/rpc.ts"
14
16
  },
15
17
  "bin": {
16
18
  "opencode-local-search": "cli.js"
@@ -18,12 +20,18 @@
18
20
  "files": [
19
21
  "cli.js",
20
22
  "src/*.ts",
23
+ "src/*.tsx",
24
+ "src/*.css",
25
+ "dist/*.cjs",
21
26
  "assets/screenshot.png",
22
27
  "README.md",
28
+ "CHANGELOG.md",
23
29
  "LICENSE"
24
30
  ],
25
31
  "scripts": {
26
- "test": "node --no-warnings --experimental-strip-types --test test/search.test.ts"
32
+ "build": "vite build",
33
+ "test": "node --no-warnings --experimental-strip-types --test test/search.test.ts",
34
+ "test:browser": "node test/search-shortcut.mjs"
27
35
  },
28
36
  "sideEffects": false,
29
37
  "engines": {
@@ -60,10 +68,22 @@
60
68
  "optional": true
61
69
  }
62
70
  },
71
+ "overrides": {
72
+ "glob": "14.0.5",
73
+ "minimatch": "11.0.8"
74
+ },
63
75
  "author": "nandoblanco",
64
76
  "license": "MIT",
65
77
  "repository": {
66
78
  "type": "git",
67
79
  "url": "git+https://github.com/nandoblanco/opencode-local-search.git"
80
+ },
81
+ "devDependencies": {
82
+ "playwright": "^1.56.0",
83
+ "@opencode/plugin": "^2.2.4",
84
+ "@opencode/theme": "^2.2.4",
85
+ "solid-js": "^1.9.18",
86
+ "vite": "^8.3.5",
87
+ "vite-plugin-solid": "^2.11.15"
68
88
  }
69
89
  }