-
Notifications
You must be signed in to change notification settings - Fork 0
Companies Surface
Relevant source files
- src/lib/Combobox.svelte
- src/lib/CreateCompanyForm.svelte
- src/lib/companies.svelte.ts
- src/lib/company.ts
- src/lib/companyView.test.ts
- src/lib/companyView.ts
- src/lib/styles/components/combobox.css
- src/lib/styles/elements.css
- src/lib/styles/layout/companies.css
- src/lib/styles/tokens.css
- src/routes/+page.svelte
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.
The surface relies on the companiesStore for data persistence and the applyView utility for UI-side logic like filtering and sorting.
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.
- Data Flow: On mount, the surface checks
cs.vaultPathand triggerscs.load()src/routes/+page.svelte#28-31 - Reactivity: Updates to individual companies (e.g., status changes or note saves) use an
applyhelper to update the localcompaniesarray, triggering Svelte's reactivity src/lib/companies.svelte.ts#24-26 - Persistence: Methods like
changeStatus,markChecked, andsaveNotescall corresponding Tauri commands defined insrc/lib/company.tssrc/lib/companies.svelte.ts#63-81
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
The following diagram illustrates the relationship between the Svelte components, the frontend view logic, and the underlying data structures.
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
Sources: src/routes/+page.svelte#1-14src/lib/companyView.ts#1-47src/lib/company.ts#3-21
The surface provides four distinct tab views and a high-performance search engine.
- Queue: Shows companies requiring attention. It uses
queueSectionsto split the list intoneverFetched(newly added) andstaleChecked(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.
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:
- Tier 0/1: Name prefix or substring match.
- Tier 2: Domain name match.
- Tier 3: Domain alias match.
- Tier 4: Notes content match (includes a
notesSnippetaround the hit) src/lib/companyView.ts#162-202
- Keyboard Navigation: The
onSearchKeyfunction handlesArrowUp/Downto change theactiveIndex,Enterto navigate to the company page, andEscapeto clear search src/routes/+page.svelte#101-138
Sources: src/routes/+page.svelte#101-138src/lib/companyView.ts#150-208
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
distincthelper src/lib/companyView.ts#133-144 - Implementation: The
Comboboxuses a portaled popover to avoid clipping and supports internal searching of its options src/lib/Combobox.svelte#91-112
Companies are rendered as button or div elements with a grid layout defined in companies.css.
- Monogram: A visual identifier derived from the company name src/lib/labels.ts
- Screening Chips: Visual indicators for
dealbreakerorcautionstatus src/lib/company.ts#19 - Metadata: Rows display the company size, stage, and
last_checkedrelative date src/routes/+page.svelte#11
Sources: src/lib/Combobox.svelte#1-203src/lib/styles/layout/companies.css#91-190src/lib/companyView.ts#133-144
New companies are added via the CreateCompanyForm.svelte modal.
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
The form supports:
- Domain Selection: Uses the
DomainPickercomponent src/lib/CreateCompanyForm.svelte#73 - Snake Case Mapping: The
NewCompanyinterface ensures frontend fields match the Rust backend's expectedsnake_casekeys src/lib/company.ts#28-41 - Manual Entry: While automated research is planned, this form handles manual entry of
business_model,location, andnotessrc/lib/CreateCompanyForm.svelte#39-52
Sources: src/lib/CreateCompanyForm.svelte#35-61src/lib/company.ts#49-51src/lib/companies.svelte.ts#82-86