Skip to content

Add --account flag to search command#1

Open
davidggphy wants to merge 1 commit intomainfrom
feat/search-account-flag
Open

Add --account flag to search command#1
davidggphy wants to merge 1 commit intomainfrom
feat/search-account-flag

Conversation

@davidggphy
Copy link
Owner

@davidggphy davidggphy commented Mar 2, 2026

Adds --account flag to msgvault search to scope results to a single account when multiple accounts are synced into the same archive.

Problem

With multiple accounts synced, search returns results from all of them interleaved, with no way to filter at query time:

$ msgvault search "budget proposal"
# results from alice@personal.com and alice@work.com mixed together

Solution

$ msgvault search "budget proposal" --account alice@work.com
# only messages belonging to alice@work.com

Implementation

Resolves the account identifier to a source_id via GetSourceByIdentifier and sets q.AccountID directly on the parsed search.Query. buildSearchQueryParts already handles AccountID, so no changes to internal packages or the Engine interface are needed. The lookup runs before ensureFTSIndex so an invalid account fails immediately.

Closes wesm#164.

Testing

go test -tags fts5 ./... passes. No new lint issues introduced (golangci-lint run ./... reports only pre-existing issues in other files).

Tested manually against a two-account archive:

# Filters to one account — returns only that account's messages
$ msgvault search "budget proposal" --account alice@work.com

# Same query on the other account — returns no results (correct)
$ msgvault search "budget proposal" --account alice@personal.com
No messages found.

# Unknown account — fails fast with a clear error
$ msgvault search "budget proposal" --account unknown@example.com
Error: account "unknown@example.com" not found

Allows scoping search results to a single account when multiple
accounts are synced into the same archive.

Resolves the account identifier to a source_id via GetSourceByIdentifier
and sets q.AccountID directly on the parsed search.Query, which
buildSearchQueryParts already handles. No interface changes needed.
@davidggphy davidggphy force-pushed the feat/search-account-flag branch from b7ddcab to 6fbb1a0 Compare March 2, 2026 17:09
@davidggphy davidggphy changed the title search: add --account flag to filter results by account Add --account flag to search command Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: --account flag for search command

1 participant