Skip to content

fix(totp): only request a code for items that carry a seed - #15

Merged
pyramation merged 1 commit into
mainfrom
fix/totp-only-for-items-with-seed
Aug 7, 2026
Merged

fix(totp): only request a code for items that carry a seed#15
pyramation merged 1 commit into
mainfrom
fix/totp-only-for-items-with-seed

Conversation

@pyramation

Copy link
Copy Markdown
Contributor

Summary

Clicking a login spammed the main process with field "seed" not found on item … once a second. ItemDetail guards the polling loop with fields.some(f => f.purpose === 'totp_seed'), but fields holds the previous item's fields until the new item's refresh() resolves — so selecting a login right after a code kept the guard true, and the poller asked for a code with the new item's id.

Two changes, either of which alone would stop the crash:

// renderer: fields can no longer outlive the item they came from
const [loaded, setLoaded] = useState<{ itemId: string; fields: VaultFieldMeta[] }>();
const fields = loaded.itemId === item.id ? loaded.fields : [];
// main: absence of a seed is a normal answer, not a raised exception
async totpEntry(itemId: string): Promise<TotpEntry | null> {
  
  if (!fields.some(f => f.purpose === 'totp_seed')) return null;

totp.code is now Promise<TotpEntry | null>; the renderer clears its interval on a null rather than re-asking every second, and totpList() filters nulls (a kind: 'totp' item whose seed was deleted no longer takes the whole Codes tab down with it). dcrypt vault totp <item> gets the same guard, reporting "<title>" has no one-time-code secret instead of surfacing the PL/pgSQL RAISE.

Link to Devin session: https://app.devin.ai/sessions/04636534e07048089ffb6b78142e12cd
Requested by: @pyramation

@pyramation pyramation self-assigned this Aug 7, 2026
@devin-ai-integration

Copy link
Copy Markdown

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@pyramation
pyramation merged commit d1455b0 into main Aug 7, 2026
5 checks passed
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.

1 participant