Skip to content

One calm pending row on Home, failures in Activity, safe retries - #21850

Merged
Git-on-my-level merged 2 commits into
mainfrom
lane/pending-work-row
Oct 16, 2026
Merged

Git-on-my-level merged 2 commits into
mainfrom
lane/pending-work-row

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

What changed and why

Home could show "Catching up on earlier audio" and a separate "Processing… taking longer than usual · Try Again" card at the same time for the same backlog. The card was driven by a fixed 2-minute client timer, so ordinary slow work looked like a failure.

  • Home: one calm "on the way" row. Conversations still processing, recordings syncing, and server-side pending work (GET /v1/pending-work) all fold into it. There are no per-conversation processing cards and no client-side timeout warning. A just-captured conversation stays visible under a folder or starred filter.
  • Failures: finalization dead-letters write one attention item per failed generation, in the same transaction. Activity shows them in a new Needs attention section with Try Again / Retry all. Recordings that failed on the phone link to Offline Sync from there. The bell lights for new recaps (as before) or, in the warning color, for unseen attention items. Seen state is stored on the server, so the phone and the Mac agree.
  • Retry safety:
    • Reprocessing runs at most once at a time per conversation generation. Concurrent callers join the active attempt, and later requests start a new attempt.
    • Failed attempts can be retried, and an abandoned attempt can be reclaimed after a 30-minute lease.
    • An Idempotency-Key replays its original attempt. The existing POST /v1/conversations/{id}/reprocess uses the same claim, so phone, Mac, and Retry all can't double-pay.
  • Removed: the retired ProcessingConversationWidget, processing_timeout.dart, the unreachable processing page, and their orphaned strings.

This ships ungated, by product decision. The app tolerates a backend without the new endpoints (404 is treated as empty), so app and backend can roll out in either order.

Backend contract and limits: backend/docs/pending-work.md.

Line-Count-Exception: backend/database/conversation_finalization_jobs.py | 2652 -> 2658 | attention item must be written inside the existing dead-letter transaction
Line-Count-Exception: backend/routers/conversations.py | 2318 -> 2355 | reprocess must claim before paid work at the existing endpoint; claim logic itself lives in database/processing_attention.py

Product invariants affected

none

How it was verified

All results below were measured on this branch in the task worktree.

  • make preflight: 44 checks passed.
  • App: TZ=UTC bash app/test.sh (full hermetic suite) → 5891 passed, 16 skipped, 0 failed. This ran before the final cleanup commit. After it, the affected suites were re-run: Activity (17), Process Now (4), Home pending-row and new pending-work tests.
  • App: app/scripts/analyze_ratchet.sh passed. python3 scripts/l10n.py check → ok, 49 locales.
  • Backend focused pytest:
    • test_pending_work.py, test_reprocess_tombstone_guard.py, test_reprocess_app_selection.py, test_conversation_finalization_jobs.py, test_live_capture_lifecycle.py → all passed.
    • That covers exactly-once item creation, resolution, concurrent claim (one paid call), sequential reprocess (both run), different app_id, key replay, retry after failure, and lease reclaim.
  • Backend: typecheck 0 errors, Black clean, dev/prod runtime_env validators passed.
  • Not verified: live behavior on a device or against a deployed backend, and Firestore contention against an emulator.

Tests

  • App: app/test/services/pending_work_store_test.dart, app/test/widgets/pending_work_test.dart, app/test/widgets/home_processing_pending_row_test.dart (replaces the processing-card placement test), app/test/pages/activity/activity_test.dart.
  • Backend: backend/tests/unit/test_pending_work.py, backend/tests/unit/test_reprocess_tombstone_guard.py.

UI evidence

UI-Evidence: none -- no device capture was taken. Home and Activity states are covered by widget tests; the design mockups were reviewed before implementation.

Failure class (fixes)

Failure-Class: none

🤖 Generated with Claude Code

View guided diff Turn on auto-fix

Home no longer draws a card per processing conversation or warns after a
fixed two-minute client timer. Conversations still processing, recordings
syncing and server-side work all fold into the one "on the way" row.

Work the server gave up on (finalization dead-letter) is recorded once per
failed generation and listed in Activity's Needs attention section with
Try Again / Retry all; it lights the bell in the warning color. Recording
failures already known on the phone link to Offline Sync from there.

Backend adds GET /v1/pending-work, the /v1/attention-items family, and a
retry claim that runs paid reprocessing at most once at a time per
conversation generation: concurrent callers join the active attempt, later
requests start a new attempt, failed and stale (30 min lease) attempts can
be retried, and an idempotency key replays its original attempt.

Removes the retired processing card, its timeout helper, the unreachable
processing page, and their orphaned strings.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-16T13:21:29.982611Z 13216f6 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Agentic security review found one medium issue on the new attention retry routes: they call the paid conversation reprocess path without the existing conversations:reprocess rate limit.

Open in Web View Automation 

Sent by Cursor Security Agent: Security Reviewer

Comment thread backend/routers/pending_work.py Outdated
Comment on lines +104 to +106
@router.post('/v1/attention-items/retry-all')
def retry_all(
request: RetryAllRequest, background_tasks: BackgroundTasks, uid: str = Depends(auth.get_current_user_uid)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Agentic Security Review
Severity: MEDIUM

New POST /v1/attention-items/retry-all and POST /v1/attention-items/{item_id}/retry invoke the same paid execute_reprocess path as POST /v1/conversations/{id}/reprocess, but they authenticate with get_current_user_uid only. The existing reprocess route is gated at 3 requests per hour (conversations:reprocess) because each run is treated as expensive (~22 OpenAI calls). Route policy records rate_limit as none. retry-all also fans out _run over every retryable item from unbounded list_items(uid).

Impact: An authenticated caller can bypass the paid-reprocess budget. Sequential retries after a failed attempt (new Idempotency-Key) start another paid run, and retry-all can start N sequential paid summarization jobs in one request, occupying shared LLM and worker capacity.

Fix in Cursor Fix in Web

Reviewed by Cursor Security Reviewer for commit cf42f70. Configure here.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cf42f7095a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +89 to +91
onRetry: item.retryable && item.retryState == AttentionRetryState.none
? () => store.retry(item)
: null,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep failed attention attempts retryable

When a retry finishes with state: failed, this predicate removes the Try Again action even though the server deliberately leaves the item active and retryable. Reopening Activity does not help because list_items() returns the same failed state; moreover, PendingWorkStore.retry() retains the completed idempotency key, so merely allowing the button would replay the failed attempt rather than start a new one. Treat failed as actionable and rotate the key after a definitive failed response.

Useful? React with 👍 / 👎.

Comment on lines +155 to +157
for item_id, operation in owned:
try:
_run(uid, item_id, operation, background_tasks)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Move retry-all work outside the request timeout

With two or more failed conversations, this loop runs each synchronous paid reprocessing pipeline serially inside /retry-all. That route has no override in backend/main.py, so it inherits the 120-second default POST timeout, while a single model call may consume 60 seconds. A batch can therefore return 504 after all claims have already been reserved, leaving later items in_progress until lease expiry and keyed replay unable to resume them; dispatch the owned operations through a bounded async/background coordinator instead.

AGENTS.md reference: backend/AGENTS.md:L263-L268

Useful? React with 👍 / 👎.

Comment on lines +548 to +550
// Conversations still processing and server-side work join the one pending row instead of
// drawing their own cards: slow work never reads as a problem on Home.
final pendingVisible = syncPendingVisible || hasProcessingConversations || _pendingWork.pending.isNotEmpty;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Refresh the server projection when processing completes

If Home initializes while a conversation is processing, _pendingWork.pending captures that row; when the normal conversation provider later reports completion, only hasProcessingConversations changes and the cached server list remains nonempty. The store is refreshed on page initialization or manual pull, but not on completion or a timer, so this new condition can leave the spinner row visible indefinitely until the user manually refreshes or opens Activity.

Useful? React with 👍 / 👎.

// Recordings say where they are; with none, what is left is conversations being processed.
final subtitle = SyncPendingWork.shouldShow(p) ? SyncPendingWork.stageLabel(p, l) : l.processing;
final now = DateTime.now();
void open() => routeToPage(context, OnTheWayPage(syncProvider: syncProvider, multiFileSync: multiFileSync));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Show server-only work on the pending details page

When the row exists solely because PendingWorkStore.pending contains work started by another device or missed by the local providers, tapping it constructs OnTheWayPage without passing that store. The destination reads only ConversationProvider.processingConversations and SyncProvider, so with both local sources empty it displays “All recordings synced” while Home still says work is processing.

Useful? React with 👍 / 👎.

from datetime import datetime, timezone

index_key = _key(f'pending_sync_jobs:{uid}')
ids = r.zrevrange(index_key, 0, 99) or []

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Fail open when the pending sync index is unavailable

If Redis is unavailable, this unguarded zrevrange raises and causes the entire /v1/pending-work request to return 500, also discarding the independently available Firestore processing-conversation projection. The same function also performs unguarded get/zrem calls; catch Redis failures, log them, and return an empty sync-job contribution so the request can proceed as required by the backend Redis contract.

AGENTS.md reference: backend/AGENTS.md:L183-L183

Useful? React with 👍 / 👎.

Comment on lines +12 to +18
from database._client import db, run_transactional

LIMIT = 100


def items_ref(uid: str) -> Any:
return db.collection('users').document(uid).collection('processing_attention_items')

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Use call-time injectable Firestore clients

The new persistence module is built entirely on the legacy global db proxy, so callers cannot inject a client per operation and tests must replace module-global state. Convert these helpers to obtain get_firestore_client() at call time and accept optional keyword-only firestore_client parameters, including propagating the same client through transactions and nested reads.

AGENTS.md reference: backend/AGENTS.md:L173-L175

Useful? React with 👍 / 👎.

Comment on lines +79 to +82
def list_items(uid: str, limit: int | None = None) -> list[dict[str, Any]]:
result: list[dict[str, Any]] = []
query = items_ref(uid).where(filter=FieldFilter('active', '==', True))
if limit is not None:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Sort attention items by creation time

PendingWorkStore.attention promises newest-first ordering and Activity renders the returned list unchanged, but this query has no order_by; its results therefore follow Firestore's document ordering rather than created_at, and the generated IDs begin with conversation IDs rather than time. Multiple failures will appear in arbitrary historical order, so explicitly request descending creation time and declare the required index.

Useful? React with 👍 / 👎.

_markSeen = markSeen ?? api.markAttentionItemsSeen,
_newKey = newKey ?? (() => const Uuid().v4());

static PendingWorkStore instance = PendingWorkStore();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Clear pending-work state when the account changes

This process-wide singleton has no owner identity or logout reset, and refresh() deliberately preserves its previous rows on transport/server failures. After account A signs out and account B signs in, B can therefore see A's pending row, warning dot, conversation title, and conversation ID whenever B's first refresh fails or while it is still in flight. Scope the cached state to the current UID and synchronously clear it as soon as the owner changes.

Useful? React with 👍 / 👎.

Comment on lines 620 to +625
if (pendingOpensToday)
const SliverToBoxAdapter(
child: Padding(padding: EdgeInsets.only(top: 10), child: HomePendingRow(showTodayHeader: true)),
SliverToBoxAdapter(
child: Padding(
padding: const EdgeInsets.only(top: 10),
child: HomePendingRow(showTodayHeader: true, pendingWork: widget.pendingWork),
),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Suppress empty states when server work is pending

When pendingOpensToday is true solely because the server projection contains work, this adds the pending row but the following API-status and no-conversations branches still run because they check only local conversations and recordings. A user can consequently see “Conversations on the way” immediately above an empty/error hero claiming there are no conversations; gate those fill-remaining branches on !showPending as well.

Useful? React with 👍 / 👎.

Comment on lines 220 to +222
} else if (_failed) {
body = OmiErrorState(message: l.activityLoadFailed, onRetry: _refresh);
} else if (_items.isEmpty) {
} else if (_items.isEmpty && !hasAttention) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Render attention despite unrelated feed failures

If both the recap and recent-changes loads fail while the attention request succeeds, _failed is true because _items ignores attention, so this branch replaces the entire page with an error state instead of showing the recovery rows. _refresh() has already called markSeen(), meaning the warning dot is also cleared for failures the user never saw; treat available attention as partial content and render it with the failure notice.

Useful? React with 👍 / 👎.

Gives the pending-work and attention-items routes pydantic response models,
exports them into the app-client OpenAPI spec (and the generated Swift and
TypeScript clients), and generates app/lib/backend/schema/gen/
pending_work_wire.g.dart. The app adapters now decode through the generated
classes instead of hand-written JSON parsing.

Updates the dead-letter title and JIT processing tests for the attention
record written in the dead-letter transaction and the extracted
execute_reprocess step.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mintlify

mintlify Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
omi 🟢 Ready View Preview Oct 16, 2026, 1:10 PM

💡 Tip: Enable Automations to automatically generate PRs for you.

@Git-on-my-level

Copy link
Copy Markdown
Member Author

CodeQL note: the 3 py/path-injection alerts it reports (#153, #154 in backend/utils/other/local_storage.py; #443 in backend/utils/stt/owner_profile.py) are pre-existing and open on main (#153 since 2026-09-12). This PR does not touch either file; the alerts are re-reported because a flow passes through files this PR edits. CodeQL is not a required check.

🤖 Generated with Claude Code

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 13216f6447

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +98 to +100
case ApiSuccess(:final data):
_replace(item.id, (i) => i.copyWith(retryState: data.state));
return true;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Remove successfully retried items from attention

When the synchronous retry returns succeeded, the server has already marked the attention item inactive, but this only changes the cached row's retry state. NeedsAttentionSection renders every entry in _attention, so the resolved failure remains as an unactionable warning until the user manually refreshes or reopens Activity; remove it locally or reload the attention projection after success.

Useful? React with 👍 / 👎.

Comment on lines +89 to +90
onRetry: item.retryable && item.retryState == AttentionRetryState.none
? () => store.retry(item)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Surface retry request failures

When the retry request encounters a transport or server failure, PendingWorkStore.retry() returns false and restores the idle state, but this callback discards that result. The user therefore sees the spinner briefly disappear with no explanation that nothing was retried; await the result and present the standard retryable error feedback when it is false.

AGENTS.md reference: app/AGENTS.md:L3-L4

Useful? React with 👍 / 👎.

Comment on lines +85 to +90
item = snapshot.to_dict() or {}
conv = db.collection('users').document(uid).collection('conversations').document(item['conversation_id']).get()
row = conv.to_dict() if conv.exists else None
if not unresolved(row):
snapshot.reference.update({'active': False, 'resolved_at': datetime.now(timezone.utc)})
continue

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Retire attention items from superseded generations

When late synced content or another finalization pass advances a conversation's generation while it still lacks an overview, this reconciliation keeps the older attention item active because it checks only unresolved(row). claim_in_transaction then rejects that item's generation mismatch, so its Try Again action always returns 409; if the new generation also dead-letters, both rows remain visible. Mark an item inactive when its stored generation no longer matches generation(row).

Useful? React with 👍 / 👎.

@Git-on-my-level
Git-on-my-level merged commit 52adad7 into main Oct 16, 2026
61 of 62 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/pending-work-row branch October 16, 2026 15:33
YinkaAdepoju added a commit to YinkaAdepoju/omi that referenced this pull request Oct 16, 2026
Main's BasedHardware#21850 replaced Home's per-conversation processing cards with one
"on the way" row for everyone. Adopt it in both arms: drop the redesign's
condensing processing row, the stage split of the pending row, and the
control arm's copy of the old processing card. The prereg no longer lists
the processing row as an arm difference.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
apoorvdarshan added a commit to apoorvdarshan/omi that referenced this pull request Oct 17, 2026
Brings the branch up to upstream main (b0280d9). 126 conflicted paths:
49 .arb files merged structurally and app_localizations regenerated; 24
Flutter pages rebuilt on upstream's current code with the branch's native
presentation wiring re-applied on top.

Upstream behaviour carried into the native paths where it fits:
- Home/Library: the processing page and per-conversation processing cards
  are gone (BasedHardware#21850); the native library projects upstream's one pending row
  (library_pending → On the Way). The native Home pending row follows in
  the next commit.
- Integrations / task integrations: a failed status read offers "Try again"
  and refreshes, in native rows too.
- Memories: locked rows read "Pending" with View Usage / Saved and open the
  usage page, not the plans sheet (BasedHardware#21474); knowledge graph fit-to-bounds
  with the controller-backed page.
- Onboarding: completion is upstream's first-capture chooser, projected as
  native rows; Bluetooth permission row.
- Chat: evidence cards removed as on mobile main (the plan no longer emits
  an evidence part); edit receipts count as renderable and keep the Flutter
  card on native; the unused native quota plans sheet is dropped in favour
  of upstream's titled sheet.
- Plans sheet, freemium prompt, usage page keep both sides (native sheet
  chrome + upstream's paywall routing, titles and analytics sources).

Tests retargeted to the new behaviour (pending row instead of processing
page, locked-row copy, Sync details → How syncing works, SyncProvider and
an inert PendingWorkStore under Home/library tests).

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01L6nc4Dq4LXiSGCnJBvD7ix
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