Skip to content

Avoid timeline rerenders while typing in prompt boxes - #1799

Merged
ymichael merged 2 commits into
get-bb:mainfrom
Roystbeef:agent/fix-composer-typing-performance
Aug 18, 2026
Merged

ymichael merged 2 commits into
get-bb:mainfrom
Roystbeef:agent/fix-composer-typing-performance

Conversation

@Roystbeef

@Roystbeef Roystbeef commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • keep the embedded timeline's add-to-chat callbacks stable across composer draft writes so typing does not invalidate visible timeline rows
  • stop ThreadDetailViewInternal from subscribing to per-keystroke draft writes when it only needs imperative addQuote and storageKey actions
  • memoize local/remote workspace-open context structurally so equal context objects do not churn the timeline-wide local-file context menu provider
  • skip the prompt's custom coordsAtPos caret measurement for ordinary native typing while retaining it for selection-only, clipboard, and drop updates
  • preserve custom text-paste caret reveal by tagging composer-handled paste transactions with the same uiEvent metadata as ProseMirror's default paste path

Fixes #1304.

Root cause

The original PR addressed two genuine local costs, but issue #1304's broader scaling path remained: ThreadDetailViewInternal subscribed to usePromptDraftStorage only for stable draft actions. Every keystroke therefore re-rendered the whole thread view. Each render also rebuilt an equal OpenInTargetContext; identity-keyed memoization recreated openPathInFileTarget, then the MarkdownLocalFileContextMenuContext.Provider value around the mounted timeline, forcing React to scan that subtree for consumers.

The thread view now uses the non-subscribing draft accessor, whose quote action shares the hook's existing implementation. useLocalOpenTargets keys its context memo on kind, hostId, and serverOrigin, preserving callback identity for semantically equal contexts without keeping stale remote context fields.

Verification

  • focused prompt/editor, embedded-chat, draft-accessor, and open-context tests: 4 files / 122 tests passed
  • pnpm exec turbo run typecheck --filter=@bb/app
  • pnpm exec turbo run lint --filter=@bb/app (0 errors; repository baseline of 147 warnings)
  • pnpm exec turbo run test --filter=@bb/app --force: 363 files / 2,870 tests passed
  • Prettier and git diff --check

AGENT GENERATED: by GPT-5

Roystbeef and others added 2 commits August 18, 2026 12:36
Draft writes changed the promptDraft object identity, which recreated the embedded timeline's add-to-chat callback on every keystroke. That invalidated ThreadTimelineRows' static renderer context and rerendered all visible rows. Depend on the stable addQuote setter instead, and avoid the prompt's custom caret layout measurement for native typing transactions.
@ymichael
ymichael force-pushed the agent/fix-composer-typing-performance branch from fae350e to 2b95ae5 Compare August 18, 2026 19:38
@ymichael
ymichael marked this pull request as ready for review August 18, 2026 19:38
@ymichael
ymichael merged commit 1446804 into get-bb:main Aug 18, 2026
9 checks passed
@Roystbeef
Roystbeef deleted the agent/fix-composer-typing-performance branch August 18, 2026 22:45
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.

Composer keystroke cost scales with the mounted timeline size

2 participants