feat(search): add node label search and source filtering#32
Merged
Conversation
babb283 to
cd1cfb9
Compare
cd1cfb9 to
0dc8d6b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pi session files support append-only node labels, but
pi-session-managerwas 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_onlyvslabels_onlybehavior 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 canonicalsourceFilterstate:all,labels_only, orcontent_only.CommandMenupath now supports source filtering, leading#all/#labels/#contenttokens, andlabels_only + empty querybrowse-all-labels mode.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:
src-tauri/src/domain/pi_session.rs, preservetarget_id/labelon session entries, and emit label-backedmessage_entriesrows fromsrc-tauri/src/data/sqlite/message_index.rssrc-tauri/src/commands/search.rswithsource_filter, label-hit precedence,match_reason = "label", and dedicatedlabels_only + empty querybrowse modeget_session_labelssupport insrc-tauri/src/commands/session_file.rs/session.rs, then wire it through runtime providers andsrc/runtime-data/sessionSource.tssrc/components/command/CommandMenu.tsx/CommandPalette.tsxso 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 changessrc/utils/session.ts,src/utils/session-tree.ts,src/components/session-tree/SessionTree.tsx, andsrc/hooks/useSessionTreeLookup.tslabel-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 mutationssrc/components/session-viewer/SessionViewerSidebar.tsxto fetch labels only while visible, key label state bysessionPath, clear current-session labels on fetch failure, and avoid reusing previous-session labels during session switchessrc/demo/search.tsandsrc/browser-dataset/search.tswith backend source-filter and dedupe semantics so non-backend runtimes behave consistentlysrc/utils/search.tspackage.jsonandpnpm-lock.yamlREADME.mdhighlights andCHANGELOG.mdunreleased notesChecks:
pnpm install --frozen-lockfilepassescargo fmt --all --checkpassescd src-tauri && cargo clippy -- -D warningspassescd src-tauri && cargo testis still not green due to pre-existing unrelated failures:commands::settings::tests::save_external_session_providers_core_clears_disabled_provider_cachecore::scanner::tests::collect_session_files_expands_opencode_db_into_virtual_sessionscore::scanner::tests::scan_sessions_with_config_hides_disabled_external_cached_sessionscargo clippy -p pi-session-cli -- -D warningsis intentionally not claimed for this PR because local green status there depends on separate out-of-scope workaround patchesExample in global search showing all labels (empty search box + "Labels" filter selected):

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

Example in session viewer search (non-empty search box matching a node label, "Default" filter selected):

Example in session viewer search (non-empty search box, "Labeled" filter selected):
