Skip to content

Move thread search SQLite reads off the serving loop - #13

Merged
Guitaraholic merged 1 commit into
mainfrom
fix/sqlite-search-off-thread
Sep 2, 2026
Merged

Move thread search SQLite reads off the serving loop#13
Guitaraholic merged 1 commit into
mainfrom
fix/sqlite-search-off-thread

Conversation

@Guitaraholic

Copy link
Copy Markdown

Human comments

What was wrong

List and sidebar already run SQLite reads on a readonly WAL worker (Datahazed/bb#4, get-bb/bb#2936). GET /threads/search still called searchThreadsWithPendingInteractionState on the serving connection. A command-palette keystroke could stall streams and other HTTP on the same Node loop. That is the leftover of get-bb/bb#1131 after the list/sidebar cut.

What changed

  • New searchThreadsWithPendingInteractionStateOffThread on the same worker, new request name.
  • Search route handler is async and awaits the off-thread result.
  • :memory: (tests, no worker) stays on the serving connection.
  • Worker result type is unknown so list and search can share the queue.

No HOST_DAEMON_PROTOCOL_VERSION bump. Search response shape is unchanged.

Why this way

Do not invent a second worker. Search is the same class of sync SQLite the list path already moved. Palette typing is the remaining user-facing stall on that connection.

Benefit to bb

Command palette / thread search no longer blocks agent streams or other HTTP while SQLite scans titles. Same product rule as #4: never block Node on sync SQLite for a read the WAL worker can own.

Harvest

Submit after get-bb get-bb#2936 so the worker exists. Copy this body onto a get-bb PR that targets a branch containing get-bb#2936, or stack.

How you verified

  • packages/db/test/sqlite-read-queue.test.ts: file-backed worker search matches the serving connection. 3 passed under Node 22 (/opt/homebrew/opt/node@22/bin, ABI 127 matching better-sqlite3).

AGENT GENERATED

List and sidebar already used the readonly WAL worker. GET /threads/search
still called searchThreadsWithPendingInteractionState on the serving
connection, so a palette keystroke could stall streams. Same worker, new
request name; :memory: stays sync.
@Guitaraholic
Guitaraholic merged commit cac29f3 into main Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant