Skip to content

The Search view returns child nodes and forgets its term and results when the tab loses focus #4199

Closed

Description

@malibio

Overview

The Search view lists nodes that are not roots, and it clears its search term and results whenever the user switches to another tab (including by opening a result) and returns.

Problem Statement

Non-root results

Searching "Graph" in the Search tab returned 20 results: 1 skill, 3 schemas, and 16 text nodes. 15 of the 16 are body paragraphs that are children of skill nodes. The database has 539 nodes of which 117 are roots.

  • search-pane.svelte calls the search_roots command. It does not restrict to roots. It sends search_semantic with include_title_matches: true and scope everything (app-lib/src/commands/embeddings.rs).
  • Semantic matching can only return roots, because only roots have embeddings. The leak is the keyword half: title_match_nodes in core/src/ops/search_ops.rs queries title_contains and content_contains across every node with no root restriction, so any child paragraph that contains the query text matches.
  • The returned node carries no parent field, so the frontend cannot filter roots on its own.

State lost on tab switch

Typed "Graph" (25 rows), switched to another tab and back: the box is empty and the view reads "Type to search your nodes."

  • pane-content.svelte (line ~196) mounts <SearchPane /> only while the Search tab is active, so switching tabs destroys the component.
  • query, results and hasSearched are component-local $state in search-pane.svelte, so they are lost with it. A search tab is created with no content, so nothing else holds them.

Proposed Solution

Restrict the keyword half of the human-facing search to root nodes, and keep each Search tab's term in state that outlives the component.

Documentation

  • ADR-029 - which node types and which nodes (roots) are embedded.
  • Frontend State & Persistence - where per-tab UI state lives.
  • No prior doc covers the Search view; add a short description to the doc that fits once the behavior is fixed.

Acceptance Criteria

  • The Search view returns only root nodes. A test creates a child node whose text matches the query and asserts it is not returned, while its root is.
  • The agent and CLI search paths (include_title_matches unset) keep their current results.
  • The search_roots command doc and the pane header describe what is actually searched.
  • Returning to a Search tab restores the term in the box and re-runs the search, so results are never stale.
  • Opening a result and coming back keeps the term.
  • Each Search tab keeps its own term.
  • A frontend test covers switching away and back.
  • Code passes bun run quality:fix; bun run test:changed passes.

Technical Specifications

Reference Files

  • packages/desktop-app/src/lib/components/search/search-pane.svelte - local state, runSearch, the search_roots invoke
  • packages/desktop-app/src/lib/components/layout/pane-content.svelte - conditional mount of SearchPane
  • packages/desktop-app/app-lib/src/commands/embeddings.rs - search_roots
  • packages/core/src/ops/search_ops.rs - title_match_nodes, merge_keyword_and_semantic, the include_title_matches input

Implementation Details

Whether NodeQuery already has a roots-only filter, or whether one is added, is for the implementer to establish. If a new flag or wire type is needed it follows the node-type and wire-type rules (generated TypeScript, bun run gen:types).

Related Issues

  • None

Activity

  1. added
    bug
    on Oct 31, 2026
  2. self-assigned this
    on Nov 2, 2026
  3. mstomar125 commented on Nov 2, 2026

    @mstomar125
    Contributor

    Picking this up (sweep drain).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

backendbugfrontendui

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions