Skip to content

fix(app): prevent composer history update loops - #1669

Merged
ymichael merged 2 commits into
get-bb:mainfrom
Flame119052:agent/fix-composer-history-update-loop
Aug 18, 2026
Merged

fix(app): prevent composer history update loops#1669
ymichael merged 2 commits into
get-bb:mainfrom
Flame119052:agent/fix-composer-history-update-loop

Conversation

@Flame119052

@Flame119052 Flame119052 commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • deduplicate composer history resets before React state dispatch
  • mark history sessions active before recall updates and inactive before reset updates

Problem

Opening a bb thread could fail with React error #185 (Maximum update depth exceeded). The production stack pointed to PromptBoxInternal's history reset effect and resetHistorySession.

Root cause

Callers may recreate an empty history object while React is processing overlapping transition and synchronous updates. Each effect pass unconditionally dispatched three null state updates. With another update lane already pending, React could not always take its eager same-value bailout, so the redundant passive-effect commit could feed another render and eventually hit the nested update limit.

Fix

The reset now uses a ref as the accepted session-transition marker. History recall marks the session active before state dispatch. Reset marks it inactive before dispatching its three clears, so inactive sessions perform no state updates and re-entrant effects cannot enqueue the same reset twice.

User impact

Thread composers no longer risk blanking the route with React #185 when empty history props are recreated during concurrent rendering. Normal history recall and reset behavior is preserved.

Validation

  • pnpm exec turbo run test --filter=@bb/app --force -- src/components/promptbox/PromptBoxInternal.test.tsx — 97 passed
  • pnpm exec turbo run typecheck --filter=@bb/app --force — passed

AGENT GENERATED: by GPT-5.6

@ymichael
ymichael marked this pull request as ready for review August 18, 2026 17:29
@ymichael
ymichael merged commit 8de95f1 into get-bb:main Aug 18, 2026
9 checks passed
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.

2 participants