Skip to content

feat(search): add node label search and source filtering#32

Merged
Dwsy merged 1 commit intoDwsy:mainfrom
w-winter:feat/node-label-search-20260411
Apr 12, 2026
Merged

feat(search): add node label search and source filtering#32
Dwsy merged 1 commit intoDwsy:mainfrom
w-winter:feat/node-label-search-20260411

Conversation

@w-winter
Copy link
Copy Markdown
Collaborator

@w-winter w-winter commented Apr 12, 2026

Pi session files support append-only node labels, but pi-session-manager was dropping that data before it reached the search index and wasn't resolving it reliably in the session tree. As a result, labeled nodes couldn't be searched globally, content_only vs labels_only behavior didn't exist, and large chunked sessions could show incomplete label state locally.

This change makes labels first-class searchable node metadata in the two UIs I believe to be most relevant: global full-text search and search of the in-session tree. Pi-specific label semantics are mirrored with a raw session parser that resolves labels by whole-file order with latest-wins and empty-label-clears behavior. Those resolved labels are indexed as source_type = "label" rows tied to the target node, ranked ahead of ordinary content hits for the same node, and exposed through one canonical sourceFilter state: all, labels_only, or content_only.

  • On the global search side, the mounted CommandMenu path now supports source filtering, leading #all / #labels / #content tokens, and labels_only + empty query browse-all-labels mode.
  • On the session viewer side, resolved labels are fetched at the sidebar boundary via getRuntimeSessionLabels(sessionPath), so tree display/search/filter behavior works correctly even when the visible entries are only a chunk of the full file.

Summary of changes:

  • Pi label parsing and indexing: add src-tauri/src/domain/pi_session.rs, preserve target_id / label on session entries, and emit label-backed message_entries rows from src-tauri/src/data/sqlite/message_index.rs
  • Global search semantics: extend src-tauri/src/commands/search.rs with source_filter, label-hit precedence, match_reason = "label", and dedicated labels_only + empty query browse mode
  • Resolved label lookup for the tree: add cached get_session_labels support in src-tauri/src/commands/session_file.rs / session.rs, then wire it through runtime providers and src/runtime-data/sessionSource.ts
  • Mounted search UI: update src/components/command/CommandMenu.tsx / CommandPalette.tsx so the canonical global-search surface supports the shared source-filter state, leading # filter tokens, label badges, and browse-all-labels behavior without rewriting the query text when the selector changes
  • Session tree behavior: make src/utils/session.ts, src/utils/session-tree.ts, src/components/session-tree/SessionTree.tsx, and src/hooks/useSessionTreeLookup.ts label-aware so labeled nodes display correctly, participate in local search, respect the labeled-only filter, preserve tree structure for Pi-specific entry types, and navigate via target nodes rather than raw label mutations
  • Sidebar lifecycle: update src/components/session-viewer/SessionViewerSidebar.tsx to fetch labels only while visible, key label state by sessionPath, clear current-session labels on fetch failure, and avoid reusing previous-session labels during session switches
  • Runtime parity: align src/demo/search.ts and src/browser-dataset/search.ts with backend source-filter and dedupe semantics so non-backend runtimes behave consistently
  • Locales and shared helpers: add source-filter / label-match strings across search locales and add shared source-filter token helpers in src/utils/search.ts
  • Tests and tooling: add and expand Rust and frontend coverage for label parsing, search filtering/browse behavior, label precedence, excluded-session handling, tree label resolution, sidebar lifecycle, and runtime parity, and declare/sync the frontend test-tooling dependencies needed for the added Vitest/jsdom coverage in package.json and pnpm-lock.yaml
  • Docs: update README.md highlights and CHANGELOG.md unreleased notes

Checks:

  • pnpm install --frozen-lockfile passes
  • cargo fmt --all --check passes
  • cd src-tauri && cargo clippy -- -D warnings passes
  • cd src-tauri && cargo test is still not green due to pre-existing unrelated failures:
    • all platforms: commands::settings::tests::save_external_session_providers_core_clears_disabled_provider_cache
    • Windows also hits scanner/opencode-related pre-existing failures:
      • core::scanner::tests::collect_session_files_expands_opencode_db_into_virtual_sessions
      • core::scanner::tests::scan_sessions_with_config_hides_disabled_external_cached_sessions
  • cargo clippy -p pi-session-cli -- -D warnings is intentionally not claimed for this PR because local green status there depends on separate out-of-scope workaround patches

Example in global search showing all labels (empty search box + "Labels" filter selected):
uhm

Example in global search showing label matches (non-empty search box + "All" -- or "Labels" -- filter selected):
second

Example in session viewer search (non-empty search box matching a node label, "Default" filter selected):
Screenshot 2026-04-12 at 4 50 52 AM

Example in session viewer search (non-empty search box, "Labeled" filter selected):
Screenshot 2026-04-12 at 4 50 57 AM

@w-winter w-winter force-pushed the feat/node-label-search-20260411 branch 2 times, most recently from babb283 to cd1cfb9 Compare April 12, 2026 03:13
@w-winter w-winter force-pushed the feat/node-label-search-20260411 branch from cd1cfb9 to 0dc8d6b Compare April 12, 2026 03:25
@w-winter w-winter marked this pull request as ready for review April 12, 2026 03:40
@Dwsy Dwsy merged commit a12e65e into Dwsy:main Apr 12, 2026
1 of 4 checks passed
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.

2 participants