Skip to main content

Overview

Glyph uses custom hooks to separate business logic from UI. Hooks handle:
  • File tree operations (load, rename, delete)
  • Editor state (save, auto-save, conflict detection)
  • Search (full-text, advanced filters)
  • AI chat (streaming, tool calls)
  • View loading (folder, tag, database views)
Hooks follow the “hooks as logic, components as UI” pattern. Components should be thin wrappers around hooks.

File Tree Hooks

useFileTree

Location: src/hooks/useFileTree.ts Manages file tree operations (load, toggle, open).

useFileTreeCRUD

Location: src/hooks/useFileTreeCRUD.ts Create, rename, delete operations.
src/hooks/useFileTreeCRUD.ts

Search Hooks

useSearch

Location: src/hooks/useSearch.ts Debounced search with result caching.

View Loading Hooks

useViewLoader

Location: src/hooks/useViewLoader.ts Loads and builds view documents (folder, tag, search, database).

Editor Hooks

useNoteEditor

Location: src/components/editor/hooks/useNoteEditor.ts Manages TipTap editor with auto-save and conflict detection.

AI Hooks

useRigChat

Location: src/components/ai/hooks/useRigChat.ts Manages streaming AI chat with tool calls.

Database Hooks

useDatabaseTable

Location: src/hooks/database/useDatabaseTable.ts Manages database view (table/board) state.

Hook Patterns

Dependencies Object Pattern

Instead of 20 individual parameters:
Good

Async Hook Pattern

For hooks that load data:

Next Steps

Components

Component architecture

Contexts

State management