perf: avoid eager description enrichment in fast consume flow #123

Open
opened 2026-03-15 17:56:27 +00:00 by Athemis · 0 comments
Owner

Expected Behavior

Self-targeted consume effects without target or formula prompts should execute the fast consume path without enriching the item description first. Description enrichment should only happen when the consume flow actually needs dialog content.

Current Behavior

The consume flow eagerly calls description enrichment even when the effect is self-targeted and no dialog is shown. That adds avoidable rich-text processing overhead to the common consume path.

Steps to Reproduce

  1. Open src/apps/actor/consume-flow.js on main.
  2. Follow the onConsumeItem() path for a self-targeted consume effect without allowTargetChange, allowFormulaChange, or prompt target mode.
  3. Observe that enrichItemDescription(item) is called before effect execution even though no dialog content is needed.
  4. Add a regression test and run pnpm test:vitest spec/apps/actor/consume-flow.spec.ts.

Context

This was found during a performance review of the newer consume-item flow. The cost is moderate rather than catastrophic, but it sits on a high-frequency path and is easy to avoid safely.

Version

main @ 4df70e90

Foundry VTT Version

Not runtime-specific; identified in the current source path during automated tests.

Operating System

Linux

Browser / App

Other

Relevant Modules

None.

### Expected Behavior Self-targeted consume effects without target or formula prompts should execute the fast consume path without enriching the item description first. Description enrichment should only happen when the consume flow actually needs dialog content. ### Current Behavior The consume flow eagerly calls description enrichment even when the effect is self-targeted and no dialog is shown. That adds avoidable rich-text processing overhead to the common consume path. ### Steps to Reproduce 1. Open `src/apps/actor/consume-flow.js` on `main`. 2. Follow the `onConsumeItem()` path for a self-targeted consume effect without `allowTargetChange`, `allowFormulaChange`, or `prompt` target mode. 3. Observe that `enrichItemDescription(item)` is called before effect execution even though no dialog content is needed. 4. Add a regression test and run `pnpm test:vitest spec/apps/actor/consume-flow.spec.ts`. ### Context This was found during a performance review of the newer consume-item flow. The cost is moderate rather than catastrophic, but it sits on a high-frequency path and is easy to avoid safely. ### Version main @ 4df70e90 ### Foundry VTT Version Not runtime-specific; identified in the current source path during automated tests. ### Operating System Linux ### Browser / App Other ### Relevant Modules None.
Athemis self-assigned this 2026-03-15 20:18:29 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Athemis/ds4#123
No description provided.