Skip to content

Add --account flag to search command#165

Open
davidggphy wants to merge 1 commit intowesm:mainfrom
davidggphy:feat/search-account-flag
Open

Add --account flag to search command#165
davidggphy wants to merge 1 commit intowesm:mainfrom
davidggphy:feat/search-account-flag

Conversation

@davidggphy
Copy link

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 #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.
@roborev-ci
Copy link

roborev-ci bot commented Mar 2, 2026

roborev: Combined Review (6fbb1a0)

Verdict: All successful
reviews found no issues, and the code appears clean.

(Note: Two automated review agents failed to complete their scans, but the successful review reported no findings.)


Synthesized from 3 reviews (agents: codex, gemini | types: default, security)

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