Skip to content

Companies Surface

Chazona Baum edited this page Jun 24, 2026 · 1 revision

Relevant source files

The Companies Surface (src/routes/+page.svelte) is the primary entry point for managing the organizational entities in the Lodestar vault. It provides a multi-tabbed interface for browsing, filtering, and searching companies, along with specialized views for the automation queue.

Overview and State Management

The surface relies on the companiesStore for data persistence and the applyView utility for UI-side logic like filtering and sorting.

companiesStore

The companiesStore is a Svelte 5 rune-based global state that manages the lifecycle of company data. It handles the initial load from the Rust backend via Tauri invoke calls and provides methods for updating company fields.

View Logic (applyView)

To keep the UI responsive, filtering, sorting, and grouping are performed in the frontend using the applyView function src/lib/companyView.ts#79-118

Feature Implementation
Filtering Filters by status, domain, remote, size, and stagesrc/lib/companyView.ts#82-90
Sorting Supports name, company_size, stage, and last_checked. It uses custom rank orders for enum-like strings (e.g., SIZE_ORDER) src/lib/companyView.ts#66-77
Grouping When the "By domain" tab is active, companies are grouped by their domain slugs. Multi-domain companies appear in every relevant group src/lib/companyView.ts#106-117

Sources: src/lib/companies.svelte.ts#1-87src/lib/companyView.ts#1-118src/routes/+page.svelte#1-68


UI Architecture

The following diagram illustrates the relationship between the Svelte components, the frontend view logic, and the underlying data structures.

Component Relationship Diagram

flowchart LR
    subgraph subGraph2 ["Data Space (Entities)"]
        COMPANY["Company Interface"]
        DOMAIN["Domain Interface"]
    end
    subgraph subGraph1 ["Logic Space (Natural Language -> Code)"]
        VIEW["applyView (View Logic)"]
        SEARCH["searchCompanies (Search Engine)"]
        STORE["companiesStore (State)"]
    end
    subgraph subGraph0 ["Routes Space"]
        PAGE["+page.svelte"]
    end
    PAGE --> STORE
    PAGE --> VIEW
    VIEW --> SEARCH
    VIEW --> COMPANY
    STORE --> COMPANY
    PAGE --> DOMAIN
Loading

Sources: src/routes/+page.svelte#1-14src/lib/companyView.ts#1-47src/lib/company.ts#3-21


Tabs and Search

The surface provides four distinct tab views and a high-performance search engine.

Tabs

  • Queue: Shows companies requiring attention. It uses queueSections to split the list into neverFetched (newly added) and staleChecked (past their check interval) src/lib/companyView.ts#121-130
  • All: A flat list of all companies.
  • By domain: Groups companies by domain.
  • Best prospects: A filtered view of high-potential targets.

Search and Keyboard Navigation

The search input src/routes/+page.svelte#150-163 triggers a "Results Mode" in applyView. When a query is present, standard sorting and grouping are suspended in favor of a relevance-ranked list src/lib/companyView.ts#94-97

  • Relevance Tiers:
  1. Tier 0/1: Name prefix or substring match.
  2. Tier 2: Domain name match.
  3. Tier 3: Domain alias match.
  4. Tier 4: Notes content match (includes a notesSnippet around the hit) src/lib/companyView.ts#162-202
  • Keyboard Navigation: The onSearchKey function handles ArrowUp/Down to change the activeIndex, Enter to navigate to the company page, and Escape to clear search src/routes/+page.svelte#101-138

Sources: src/routes/+page.svelte#101-138src/lib/companyView.ts#150-208


Filters and Row Rendering

Combobox Filters

Filters are implemented using the Combobox component src/lib/Combobox.svelte

  • Dynamic Options: Filter options (Status, Domain, Size, etc.) are derived dynamically from the current company set using the distinct helper src/lib/companyView.ts#133-144
  • Implementation: The Combobox uses a portaled popover to avoid clipping and supports internal searching of its options src/lib/Combobox.svelte#91-112

Company Rows

Companies are rendered as button or div elements with a grid layout defined in companies.css.

Sources: src/lib/Combobox.svelte#1-203src/lib/styles/layout/companies.css#91-190src/lib/companyView.ts#133-144


CreateCompanyForm Modal

New companies are added via the CreateCompanyForm.svelte modal.

Data Flow: Creating a Company

sequenceDiagram
    participant User
    participant Form as CreateCompanyForm.svelte
    participant Store as companiesStore
    participant Rust as Tauri (create_company)
    User->>Form: Enter Name, Domain, etc.
    User->>Form: Click "Create"
    Form->>Form: validate (name required)
    Form->>Store: create(NewCompany)
    Store->>Rust: invoke("create_company" | payload)
    Rust-->>Store: Company (JSON)
    Store->>Store: Add to state & sort
    Store-->>Form: Company object
    Form-->>User: oncreated(slug) / Redirect
Loading

The form supports:

Sources: src/lib/CreateCompanyForm.svelte#35-61src/lib/company.ts#49-51src/lib/companies.svelte.ts#82-86

Clone this wiki locally