Implementation:0xranx OpenContext IdeaService
| Knowledge Sources | |
|---|---|
| Domains | Knowledge_Management, Ideas |
| Last Updated | 2026-10-24 12:00 GMT |
Overview
Concrete tool for managing idea threads and entries in the OpenContext idea journaling system, provided by the UI service layer.
Description
The IdeaService class is the business logic layer for the idea journaling module. It wraps a storage adapter (typically `LocalStorageAdapter`) and provides methods for creating threads, adding entries, searching, filtering, and grouping by date.
The service is storage-agnostic: it delegates all persistence to the adapter, allowing different storage backends (local files, cloud, etc.) without changing the business logic. The current implementation uses `LocalStorageAdapter` which stores ideas as Markdown files under `.ideas/{box}/{year}/{month}/`.
Key methods:
- createIdea: Creates a new idea thread with an initial entry.
- continueThread: Adds a new entry to an existing thread.
- getAllThreads: Lists all threads with optional filtering (date, search, box).
- searchThreads: Searches threads by keyword.
- getThreadsGroupedByDate: Groups threads by creation date.
- getAllEntriesGroupedByDate: Groups all entries across all threads by date (for timeline view).
- updateEntry / deleteThread / deleteEntry: CRUD operations.
- moveThread: Moves a thread to a different idea box.
- listBoxes / createBox / renameBox / deleteBox: Idea box management.
Usage
- Idea Journaling: Create threads to capture ideas, add entries over time.
- Timeline display: Use `getAllEntriesGroupedByDate` for the timeline UI view.
- Search: Use `searchThreads` for keyword-based idea retrieval.
- Box management: Organize ideas into boxes (inbox, projects, archive, etc.).
Code Reference
Source Location
- Repository: OpenContext
- File: src/ui/src/services/idea/IdeaService.js
- File (adapter): src/ui/src/services/idea/LocalStorageAdapter.js
- File (abstract adapter): src/ui/src/services/idea/IdeaStorageAdapter.js
Signature
export class IdeaService {
/** @param {IdeaStorageAdapter} adapter */
constructor(adapter) { this.adapter = adapter; }
async getAllThreads(filter = {}) { ... }
async getThreadsByDate(date, options = {}) { ... }
async searchThreads(keyword, options = {}) { ... }
async getThread(threadId) { ... }
async createIdea(content, options = {}) { ... }
async continueThread(threadId, content, options = {}) { ... }
async updateEntry(entryId, content) { ... }
async deleteThread(threadId) { ... }
async deleteEntry(entryId) { ... }
async moveThread(threadId, targetBox) { ... }
async getThreadsGroupedByDate() { ... }
async getAllEntriesGroupedByDate() { ... }
async getAvailableDates() { ... }
// Box management
async listBoxes() { ... }
async createBox(name) { ... }
async renameBox(oldName, newName) { ... }
async deleteBox(name) { ... }
}
Import
import { IdeaService } from './services/idea/IdeaService';
import { LocalStorageAdapter } from './services/idea/LocalStorageAdapter';
const ideaService = new IdeaService(new LocalStorageAdapter(api));
I/O Contract
Inputs (createIdea)
| Name | Type | Required | Description |
|---|---|---|---|
| content | string | Yes | Idea text content |
| options.title | string | No | Optional thread title |
| options.isAI | boolean | No | Whether AI-generated (default false) |
| options.images | string[] | No | Base64 image data |
| options.box | string | No | Idea box name (default "inbox") |
Outputs (createIdea)
| Name | Type | Description |
|---|---|---|
| returns | Promise<Thread> | Created thread object |
| Thread.id | string | Thread UUID |
| Thread.title | string | Thread title |
| Thread.entries | Entry[] | Array of entries |
| Thread.createdAt | Date | Creation timestamp |
| Thread.box | string | Box name |
| Thread.path | string | File path |
Entry Structure
| Name | Type | Description |
|---|---|---|
| Entry.id | string | Entry UUID |
| Entry.content | string | Entry text content |
| Entry.createdAt | Date | Creation timestamp |
| Entry.isAI | boolean | Whether AI-generated |
| Entry.images | string[] | Base64 image data |
Usage Examples
Create an Idea
import { IdeaService } from './services/idea/IdeaService';
import { LocalStorageAdapter } from './services/idea/LocalStorageAdapter';
const ideaService = new IdeaService(new LocalStorageAdapter(api));
// Create a new idea thread
const thread = await ideaService.createIdea(
'Consider using LanceDB for vector storage instead of FAISS',
{ title: 'Vector DB choice', box: 'projects' }
);
console.log(`Created thread: ${thread.id}`);
Add an Entry
// Continue an existing thread
const entry = await ideaService.continueThread(
thread.id,
'After testing, LanceDB is simpler to deploy and handles our scale.',
{ isAI: false }
);
Search and Timeline
// Search by keyword
const results = await ideaService.searchThreads('LanceDB');
// Get timeline entries grouped by date
const timeline = await ideaService.getAllEntriesGroupedByDate();
timeline.forEach(group => {
console.log(`${group.date} (${group.relativeDate}):`);
group.entries.forEach(entry => {
console.log(` [${entry.type}] ${entry.content.substring(0, 80)}`);
});
});