f851a087f2
Issue #480: The --quota flag on 'uwf thread read' was not properly limiting output size due to an off-by-one error in selectByQuota(). Root cause: - Items were added to selected array BEFORE checking if they would exceed the quota - This meant the last item that exceeded quota was still included - Prompt deduplication tracking was mutated during quota calculation, causing prompts to not render in final output Fix: - Check quota BEFORE adding items to selected array - Always include at least one step even if it exceeds quota - Calculate step lengths using actual rendering format - Account for start section and separators in quota calculation - Use temporary Set during length calculation to avoid mutating the prompt deduplication tracking Tests: - Added comprehensive test suite (thread-read-quota.test.ts) - Covers quota enforcement, boundary conditions, edge cases - Tests interaction with --before and --start flags - All tests pass Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>