-
Notifications
You must be signed in to change notification settings - Fork 73
Description
Problem
The TUI only works with local data. CLI commands (search, stats, list-senders, etc.) support remote servers via [remote] config, but the TUI always opens a local SQLite database directly.
For NAS/remote deployments, users can query their archive via CLI but cannot use the interactive TUI to explore it.
Root Cause
The TUI uses query.Engine which requires aggregate operations (Aggregate, SubAggregate, SearchFastWithStats) that the remote HTTP API doesn't expose. The remote store only implements MessageStore (list, get, search).
Proposed Solution
Add aggregate API endpoints to the server and implement a RemoteEngine that satisfies query.Engine over HTTP:
-
New API endpoints:
GET /api/v1/aggregate— group-by aggregation (senders, domains, labels, time, etc.)GET /api/v1/aggregate/sub— drill-down sub-aggregation with filtersGET /api/v1/stats/total— total stats with filter options
-
New
RemoteEngineininternal/remote/that implementsquery.Engineby calling these endpoints. -
Update
tui.goto checkIsRemoteMode()and useRemoteEnginewhen remote config is present.
Interface Reference
The query.Engine interface (internal/query/engine.go):
type Engine interface {
Aggregate(ctx, groupBy, opts) ([]AggregateRow, error)
SubAggregate(ctx, filter, groupBy, opts) ([]AggregateRow, error)
ListMessages(ctx, filter) ([]MessageSummary, error)
GetMessage(ctx, id) (*MessageDetail, error)
Search(ctx, query, limit, offset) ([]MessageSummary, error)
SearchFastWithStats(ctx, query, queryStr, filter, statsGroupBy, limit, offset) (*SearchFastResult, error)
GetTotalStats(ctx, opts) (*TotalStats, error)
ListAccounts(ctx) ([]AccountInfo, error)
Close() error
}
Current State
- CLI remote support works via
store_resolver.go→remote.Store - TUI hardcodes
store.Open()atcmd/msgvault/cmd/tui.go:55 - The limitation is documented in the docs site