Skip to content

[Feature] Embedded Search Results (Live Query Blocks) #169

@CodeWithInferno

Description

@CodeWithInferno

📋 Description

Add support for embedded search result blocks that auto-update when matching notes change, similar to Dataview queries in Obsidian.

🎯 Goal

Allow users to create dynamic note sections that display search results inline, automatically updating as the workspace changes.

✨ Use Cases

1. Dashboard Pages

# My Dashboard

## Recent Work Notes
```query
tag:#work modified:last-7-days

High Priority Tasks

[ ] tag:#urgent

### 2. Project Indexes
```markdown
# Project X

## All Related Notes
```query
tag:#project-x OR [[Project X]]

### 3. Content Collections
```markdown
# Reading List

```query
tag:#book status:unread

## 🔧 Implementation

### Phase 1: Basic Search Queries

```javascript
// src/core/search/QueryBlock.jsx
const QueryBlock = ({ query }) => {
  const [results, setResults] = useState([]);
  
  useEffect(() => {
    const search = async () => {
      const matches = await searchEngine.query(query);
      setResults(matches);
    };
    
    search();
    
    // Re-run when workspace changes
    const unsubscribe = workspaceEvents.on('file-changed', search);
    return unsubscribe;
  }, [query]);
  
  return (
    <div className="query-results">
      {results.map(result => (
        <QueryResultItem key={result.path} result={result} />
      ))}
    </div>
  );
};

Phase 2: Advanced Query Syntax

Support operators:

  • tag:#work - Filter by tag
  • modified:last-7-days - Time-based filters
  • folder:Projects - Folder filters
  • AND, OR, NOT - Boolean logic
  • [ ] - Incomplete tasks only
  • [x] - Completed tasks only

Phase 3: Display Options

```query
tag:#work
---
format: list | table | cards
sort: modified | created | title
limit: 10
show: title, preview, tags

## 📚 Similar Features

- **Obsidian Dataview**: Complex query language with tables
- **Logseq**: Live query blocks with advanced queries
- **Notion**: Database views with filters

## 🎨 UI Design

Query blocks should:
- Have distinct visual style (border, background)
- Show "Live" indicator
- Display result count
- Allow edit query inline
- Show loading state during search

## ✅ Success Criteria

- [ ] Basic query syntax parser
- [ ] Live-updating results
- [ ] Multiple display formats
- [ ] Performance optimized (debounced)
- [ ] Edit query in place
- [ ] Export query results
- [ ] Tests added

## 🔗 Related Features

- Builds on existing search (#73)
- Works with Bases system (#159)
- Integrates with tags (#58)

## 📊 Priority

**MEDIUM** - Powerful feature but not critical, can be added after basic search is solid.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions