Skip to content

Summary not preserved when user is not looking at the tab during generation #4199

@devin-ai-integration

Description

@devin-ai-integration

Problem

When a summary is being generated and the user switches away from the session tab, the generated summary is not saved/preserved. The summary generation continues in the background (via Zustand), but the React-based handleEnhanceSuccess callback in useAutoEnhanceRunner doesn't fire because the component unmounts when the tab loses focus.

Root Cause

PR #3881 (5dae51ff4) fixed this by adding an onComplete callback to the generate() call in runner.ts. This callback runs in Zustand's async context (not React lifecycle), so it persists even when the tab component unmounts.

However, this fix was accidentally removed in commit 789c8643c (PR #3942 - "Chat various improvements"), causing the bug to regress.

Current State

  • runner.ts: The generate() call at line ~187 has no onComplete callback. It relies on a React useEffect (line ~114) watching task state transitions, which only works while the component is mounted.
  • options-menu.tsx: The manual "enhance" trigger (triggerEnhance) at line ~103 still has the onComplete callback — so manual enhancement survives tab switches, but auto-enhancement does not.

How to Reproduce

  1. Start a recording session
  2. Stop recording (auto-enhance triggers)
  3. Switch to a different tab while the summary is generating
  4. Switch back — the summary content is lost

Previous Fix Attempts

Suggested Fix

Re-add the onComplete callback to the generate() call in apps/desktop/src/hooks/autoEnhance/runner.ts, similar to how options-menu.tsx does it. This ensures the summary is persisted via TinyBase even when the React component unmounts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions