uttrflow / uttrflow/uttrflow-swift

A huge stored retention period makes the Insights page build one bar per day, e.g. 100,000 bars

Open Beginner friendly
#500 0 comments 0 reactions 0 assignees View on GitHub
area:dictation bug good first issue P2 performance
Dominant language
Swift
Stars
4
Forks
17
Avg merge
3h 32m
Merged PRs (30d)
277

Description

## What happens

Settings only offers 1, 3, 7, 14, 30 or 90 days (`Sources/UttrflowUX/SettingsChoices.swift:108`), but decoding the settings file only refuses values of zero or less: `Settings.retention` (`Sources/UttrflowSettings/SettingsStore.swift:209-211`) keeps any positive number, for both `transcriptRetentionDays` and `clipboardRetentionDays` (lines 194-203).

`InsightsPresenter.bars` (`Sources/UttrflowUX/InsightsPresentation.swift:211`) then builds one `InsightsDay` per day of that window, so a settings file holding `100000` makes the page compute and draw 100,000 bars every time it is shown.

## Why it matters

The settings file is plain JSON in Application Support. A hand edit, an old build or a corrupt write should not be able to make a page hang.

## How to check

`Settings.retention(100_000)` returns `100000`. An `InsightsPresenter` test with that setting and one history entry produces 100,000 days.

## Acceptance criteria

- `Settings` has a named ceiling for retention, and `Settings.retention` clamps to it. Use 365 days: the existing test "keeps a retention the user actually chose" (`SettingsStoreTests.swift:232`) keeps 365, and every offered period is below it.
- Both retention fields are clamped when decoding.
- Tests: a value above the ceiling decodes to the ceiling; the existing values 1, 30 and 365 are kept; an `InsightsPresentationTests` case shows the bar count is bounded.
- A test in `UttrflowUXTests` checks that every value in `SettingsRetention.offeredDays` is at or below the ceiling, so the two cannot drift.

## Where to start

- `Sources/UttrflowSettings/SettingsStore.swift:194-211`
- `Sources/UttrflowUX/InsightsPresentation.swift:200-226`
- Tests to extend: `Tests/UttrflowSettingsTests/SettingsStoreTests.swift`, `Tests/UttrflowUXTests/InsightsPresentationTests.swift`.
- Before pushing, run `make verify` (export DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer first). It is the same command CI runs, and it enforces the 95% coverage floor per module.
- Read [CONTRIBUTING.md](https://github.com/uttrflow/uttrflow-swift/blob/main/CONTRIBUTING.md) first, and say on this issue that you are taking it.

**Size:** S, about 2-3 hours.

Contributor guide

Open the contributing guide

Research direction

Read CONTRIBUTING.md, then inspect Settings.retention in Sources/UttrflowSettings/SettingsStore.swift and InsightsPresenter.bars in Sources/UttrflowUX/InsightsPresentation.swift. Extend SettingsStoreTests.swift and InsightsPresentationTests.swift, and add the offered-days ceiling check in UttrflowUXTests. Done means both retention fields are bounded at 365, existing values remain unchanged, bar counts stay bounded, and make verify passes.

Written by the indexing model from the issue text.

Assessment

Tech stack
macos, swift
Domain
desktop, performance
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
88/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.