Skip to content

chore: remove unused memories-created quota/limit (display-only) - #7426

Merged
kodjima33 merged 4 commits into
mainfrom
chore/remove-memories-created-limit
May 21, 2026
Merged

kodjima33 merged 4 commits into
mainfrom
chore/remove-memories-created-limit

Conversation

@kodjima33

Copy link
Copy Markdown
Collaborator

Why

The mobile app showed a "5,000 memories created this month" quota bar, but nothing enforced it — the limit was display-only. Removing it everywhere.

Changes

Backend

  • Drop PlanLimits.memories_created and memories_created_used/_limit from UserSubscriptionResponse + all the plumbing that set/computed them.
  • Remove BASIC_TIER_MEMORIES_CREATED_LIMIT_PER_MONTH from all 4 helm charts.

App

  • Remove the "X of Y memories created this month" progress bar.
  • Remove memoriesCreated/memoriesCreatedUsed/memoriesCreatedLimit from the subscription model (+ regenerated subscription.g.dart).
  • Remove the memoriesUsedThisMonth l10n key across all 49 locales (+ regenerated localizations).

Kept: the memories_created usage metric and the "memories created" line in the usage history graph (real analytics).

Verification

  • flutter analyze clean (one pre-existing unrelated lint); flutter gen-l10n zero untranslated warnings.
  • Backend modules parse; test_subscription_plans passes. The other failing subscription/sync tests reproduce on clean main (pre-existing).

🤖 Generated with Claude Code

kodjima33 and others added 4 commits May 21, 2026 01:52
… Sentry captures

Transient network/socket errors (offline, timeouts, dropped connections,
cancellations) and high-frequency repeated errors (per-frame ffmpeg writes,
per-cycle assistant failures, DB-constraint loops) dominated Sentry event
volume without being actionable. logError now drops non-actionable transient
network/IO errors and collapses identical errors via a digit-normalized key
to ~one capture per 5-minute window. Local file logs + breadcrumbs unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The screenshots.imagePath column is NOT NULL, but the model field is optional
(nil for video-based screenshots). Coalesce nil to empty string on insert so a
video screenshot never trips a NOT NULL constraint violation.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…threshold

Extend the transient-network exception filter to the full set of offline/timeout/
dropped-connection codes (NSURLError + NSPOSIX), drop backend Gemini key-expiry
noise (a server config issue, not a per-client bug), and raise appHangTimeoutInterval
to 3s so only sustained freezes users feel are reported.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…nsert fix

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@kodjima33
kodjima33 merged commit ebccf07 into main May 21, 2026
3 checks passed
@kodjima33
kodjima33 deleted the chore/remove-memories-created-limit branch May 21, 2026 06:47
@greptile-apps

greptile-apps Bot commented May 21, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Note: The PR title and description reference removing a memories-created quota from the Flutter app and backend, but the actual diff contains only desktop macOS Swift changes — Sentry noise reduction and a database constraint fix. The description appears to belong to a different PR.

The desktop changes add transient-error filtering and a 5-minute dedup window to logError, expand the beforeSend exception filter to cover the full set of transient network codes and Gemini key-expiry messages, raise the app-hang threshold to 3 s, and fix a NOT NULL constraint crash when inserting video-based screenshots with a nil imagePath.

  • Sentry noise control (Logger.swift, OmiApp.swift): Two-layer filtering — isNonActionableTransient / shouldCaptureToSentry in logError, plus a beforeSend guard — prevents transient network errors and repeated identical failures from flooding Sentry event quotas.
  • DB constraint fix (RewindDatabase.swift): Coalesces nil imagePath → \"\" before insert to prevent the NOT NULL violation; the empty-string sentinel is consistent with how RewindIndexer already creates video-based screenshot records, but the delete code path in RewindViewModel only nil-guards imagePath and would call deleteScreenshot(relativePath: \"\") for any record inserted this way.

Confidence Score: 3/5

The Sentry filtering changes are safe, but the imagePath coalesce fix needs a matching guard in the delete path before this is fully correct.

The nil to empty-string coalesce in insertScreenshot means video-based screenshots are now inserted successfully, but deleteScreenshot(id:) reads imagePath back as Optional of empty string (non-nil), so RewindViewModel's if-let binds the empty string and calls deleteScreenshot with an empty relativePath. Foundation's appendingPathComponent with an empty string resolves to the screenshots directory root; fileExists returns true for directories so removeItem could target that root. RewindIndexer already stores imagePath as empty string directly so this path pre-existed, but insertScreenshot now adds a second trigger for the same condition.

desktop/Desktop/Sources/Rewind/Core/RewindDatabase.swift — the imagePath coalesce fix needs a corresponding guard in the delete path; desktop/Desktop/Sources/Logger.swift — dedup map cap logic.

Important Files Changed

Filename Overview
desktop/Desktop/Sources/Logger.swift Adds transient-error filter and 5-minute dedup window for Sentry captures; dedup map cap can be a no-op during rapid burst errors exceeding 500 unique keys.
desktop/Desktop/Sources/OmiApp.swift Raises app-hang threshold to 3s, expands network error code filter to cover the full set of transient codes, and adds a Gemini API-key-expiry suppression filter in beforeSend.
desktop/Desktop/Sources/Rewind/Core/RewindDatabase.swift Coalesces nil imagePath to empty string before insert to prevent NOT NULL constraint crash; the empty-string sentinel then passes through the nil-guard in RewindViewModel's delete path, potentially reaching RewindStorage.deleteScreenshot with an empty relative path.
desktop/CHANGELOG.json Adds three unreleased changelog entries describing the Sentry noise-reduction and DB constraint fix.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[logError called] --> B[Write to local log + breadcrumb]
    B --> C{isNonActionableTransient?}
    C -- Yes --> D[Return — local log only]
    C -- No --> E{shouldCaptureToSentry?}
    E -- No, within 5-min window --> F[Return — deduplicated]
    E -- Yes --> G[SentrySDK.capture]
    G --> H{beforeSend filter in OmiApp}
    H -- Transient network or Gemini key error --> I[Return nil — dropped]
    H -- Pass --> J[Event sent to Sentry]

    K[insertScreenshot with nil imagePath] --> L[Coalesce nil to empty string]
    L --> M[SQLite INSERT succeeds]
    M --> N[deleteScreenshot reads imagePath as Optional empty string]
    N --> O{if let imagePath = result.imagePath}
    O -- binds empty string, passes nil guard --> P[deleteScreenshot relativePath empty string]
    P --> Q[appendingPathComponent empty string]
    Q --> R[Potential: references screenshots directory root]
Loading

Reviews (1): Last reviewed commit: "chore(desktop): changelog for Sentry noi..." | Re-trigger Greptile

Comment on lines +193 to +197
// Bound the map so it can't grow unbounded over a long session.
if sentryLastCaptured.count > 500 {
let cutoff = now.addingTimeInterval(-sentryDedupWindow)
sentryLastCaptured = sentryLastCaptured.filter { $0.value > cutoff }
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Dedup-map cap is ineffective during rapid error bursts

When more than 500 unique error keys are generated within a single 5-minute window, sentryLastCaptured.count > 500 triggers the cleanup, but filter { $0.value > cutoff } keeps every entry that is still inside the dedup window — meaning all recently added entries survive and the map is not pruned at all. In a high-error scenario (e.g. a tight loop emitting 600 distinct messages), the cap never actually limits growth. Consider evicting by LRU or removing the oldest half unconditionally when count > 500 rather than relying on a time-window filter that can be a no-op.

// The `imagePath` column is NOT NULL in the schema, but the model field is
// optional (nil for video-based screenshots). Coalesce nil → "" so a video
// screenshot never trips a NOT NULL constraint violation on insert.
if record.imagePath == nil { record.imagePath = "" }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 The coalesce nil → "" now means row["imagePath"] as String? in deleteScreenshot(id:) returns Optional("") (non-nil) for every video-based screenshot. RewindViewModel then calls RewindStorage.deleteScreenshot(relativePath: ""). Foundation's appendingPathComponent("") resolves to the directory root itself — fileManager.fileExists returns true for directories, so removeItem would attempt to delete the screenshots directory root. Add a guard in RewindStorage.deleteScreenshot or in RewindViewModel's delete handler to skip empty paths.

Suggested change
if record.imagePath == nil { record.imagePath = "" }
if record.imagePath == nil || record.imagePath!.isEmpty { record.imagePath = "" }

kodjima33 added a commit that referenced this pull request May 21, 2026
Re-do of #7426, which merged the wrong commit and did not actually land
these changes.

## Why
The mobile app showed a "5,000 memories created this month" quota bar,
but nothing enforced it — display-only. Removing it everywhere.

## Changes
**Backend**: drop `PlanLimits.memories_created` +
`memories_created_used`/`_limit` from `UserSubscriptionResponse` and all
plumbing; remove `BASIC_TIER_MEMORIES_CREATED_LIMIT_PER_MONTH` from all
4 helm charts.
**App**: remove the quota progress bar, the `memoriesCreated*`
subscription fields (+ regenerated `subscription.g.dart`), and the
`memoriesUsedThisMonth` l10n key across all 49 locales (+ regenerated
localizations).
**Kept**: the `memories_created` usage metric and the usage-history
graph line (real analytics).

🤖 Generated with [Claude Code](https://claude.com/claude-code)
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