Skip to content

fix(chat): prevent flicker from rapid 'Load older history' clicks - #42

Merged
marcelormendes merged 1 commit into
mainfrom
fix/load-older-history-flicker
Aug 14, 2026
Merged

fix(chat): prevent flicker from rapid 'Load older history' clicks#42
marcelormendes merged 1 commit into
mainfrom
fix/load-older-history-flicker

Conversation

@marcelormendes

Copy link
Copy Markdown
Owner

Summary

Fixes chat flicker caused by rapidly clicking "Load older history" in the Electron renderer chat panel. Each click previously enqueued a serial read('older'); a burst churned the whole conversation history page-by-page, and each page triggered a full timeline re-render plus the scroll-anchoring layout effect, producing visible flickering.

The fix adds a per-pane in-flight guard in ConversationChatPanelForPane:

  • loadOlder now returns early (no-op) when an older read is already pending or no older page exists, sets a synchronous loadingOlderRef, and clears it in a finally.
  • The "Load older history" button is disabled and shows a "Loading older history…" label while a load is in flight, then re-enables on completion.

Validation

  • npm run verify passes locally (typecheck, biome lint, 584 vitest tests, site:build).
  • src/renderer/chat/ConversationChatPanel.test.tsx adds regression coverage:
    • rapid clicks dedupe to a single in-flight older read,
    • button disabled + loading label while pending, re-enabled after resolution,
    • subsequent single clicks still work and use the updated olderCursor.
  • Manual reproduction steps: with the chat panel open, scroll to the top, throttle the engine read, click "Load older history" 20+ times within ~1s — only one older read executes and no page-jump flicker occurs.

Checklist

  • The change is focused and does not include unrelated work.
  • Tests cover the new behavior.
  • npm run verify passes locally.
  • No credentials, tokens, private data, or generated build artifacts are included.

Guard loadOlder against re-entry with a per-pane in-flight flag so a
burst of clicks enqueues only a single 'older' read instead of churning
the timeline page-by-page and re-rendering/flickering the whole panel.
Disable the button and show a loading label while an older read is
pending, and clear the guard in finally so later single clicks still
work with the updated olderCursor.

Adds regression coverage for click deduplication, the disabled/loading
button state, and cursor dedup.
@marcelormendes
marcelormendes merged commit 29c918e into main Aug 14, 2026
2 checks passed
@marcelormendes
marcelormendes deleted the fix/load-older-history-flicker branch August 14, 2026 06:57
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